@@ -11,8 +11,7 @@ use aes_gcm_siv::{
1111use anyhow:: { Context , Result , anyhow} ;
1212use colored:: Colorize ;
1313use copy_metadata:: copy_metadata;
14- use die_exit:: die;
15- use log:: { debug, info} ;
14+ use log:: { debug, info, warn} ;
1615use rayon:: { iter:: IntoParallelRefIterator , prelude:: * } ;
1716use sha3:: { Digest , Sha3_224 } ;
1817use tap:: Tap ;
@@ -102,10 +101,13 @@ fn try_compress(bytes: Box<[u8]>, path: PathBuf, level: u8) -> anyhow::Result<(V
102101 Ok ( (
103102 compressed,
104103 path. append_ext ( COMPRESSED_EXTENSION )
105- . tap ( |p| debug ! ( "Compressed to: {} " , p. display( ) ) ) ,
104+ . tap ( |p| debug ! ( "Compressed to: `{}` " , p. display( ) ) ) ,
106105 ) )
107106 } else {
108- info ! ( "Compressed data size is larger than origin, do not compress." ) ;
107+ info ! (
108+ "Compressed data size is larger than origin, do not compress `{}`." ,
109+ path. display( )
110+ ) ;
109111 Ok ( ( bytes. into_vec ( ) , path) )
110112 }
111113}
@@ -148,7 +150,10 @@ pub fn encrypt_file(
148150 ) ;
149151 return Ok ( new_file) ;
150152 }
151- println ! ( "Encrypting file: {}" , format!( "{}" , file. display( ) ) . green( ) ) ;
153+ info ! (
154+ "Encrypting file: `{}`" ,
155+ format!( "{}" , file. display( ) ) . green( )
156+ ) ;
152157 let bytes = fs:: read ( file) . with_context ( || format ! ( "{}" , file. display( ) ) ) ?;
153158
154159 let ( encrypted, new_file) = {
@@ -168,10 +173,7 @@ pub fn decrypt_file(
168173 file : impl AsRef < Path > + Send + Sync ,
169174 key : & ' static [ u8 ] ,
170175) -> anyhow:: Result < PathBuf > {
171- println ! (
172- "Decrypting file: {}" ,
173- format!( "{}" , file. as_ref( ) . display( ) ) . green( )
174- ) ;
176+ info ! ( "Decrypting file: {}" , file. as_ref( ) . display( ) ) ;
175177 let new_file = file. as_ref ( ) . to_owned ( ) ;
176178 let bytes = fs:: read ( & file) . with_context ( || format ! ( "{}" , file. as_ref( ) . display( ) ) ) ?;
177179
@@ -196,9 +198,10 @@ pub fn decrypt_file(
196198pub fn encrypt_repo ( repo : & ' static Repo ) -> anyhow:: Result < ( ) > {
197199 assert ! ( !repo. get_key( ) . is_empty( ) , "Key must not be empty" ) ;
198200 let patterns = & repo. conf . crypt_list ;
199- if patterns. is_empty ( ) {
200- die ! ( "No file to encrypt, please exec `git-se add <FILE>` first." ) ;
201- }
201+ assert ! (
202+ !patterns. is_empty( ) ,
203+ "No file to encrypt, please exec `git-se add <FILE>` first."
204+ ) ;
202205 repo. add_all ( ) ?;
203206 let encrypt_result = repo
204207 . ls_files_absolute_with_given_patterns (
@@ -209,10 +212,7 @@ pub fn encrypt_repo(repo: &'static Repo) -> anyhow::Result<()> {
209212 . collect :: < Vec < _ > > ( ) ;
210213 encrypt_result. par_iter ( ) . for_each ( |ret| {
211214 if let Err ( err) = ret {
212- eprintln ! (
213- "{}" ,
214- format!( "warning: failed to encrypt file: {err}" ) . yellow( )
215- ) ;
215+ warn ! ( "warning: failed to encrypt file: {err}" ) ;
216216 }
217217 } ) ;
218218 repo. add_all ( ) ?;
@@ -242,10 +242,7 @@ pub fn decrypt_repo(repo: &'static Repo, path: Option<impl AsRef<Path>>) -> anyh
242242 . collect :: < Vec < _ > > ( ) ;
243243 decrypt_results. par_iter ( ) . for_each ( |ret| {
244244 if let Err ( err) = ret {
245- eprintln ! (
246- "{}" ,
247- format!( "warning: failed to decrypt file: {err}" ) . yellow( )
248- ) ;
245+ warn ! ( "warning: failed to decrypt file: {err}" ) ;
249246 }
250247 } ) ;
251248 repo. add_all ( ) ?;
0 commit comments