@@ -17,6 +17,7 @@ fn file_creator(
1717 name : & str ,
1818 extension : & str ,
1919 truncate : bool ,
20+ write : bool ,
2021) -> std:: result:: Result < std:: fs:: File , std:: io:: Error > {
2122 let mut path_buffer = PathBuf :: new ( ) ;
2223 path_buffer. push ( std:: env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
@@ -26,7 +27,7 @@ fn file_creator(
2627 let mut options = OpenOptions :: new ( ) ;
2728 let file = options
2829 . read ( true )
29- . write ( true )
30+ . write ( write )
3031 . truncate ( truncate)
3132 . create ( true )
3233 . open ( & path_buffer) ;
@@ -293,7 +294,7 @@ pub(crate) fn compare_enum_cache(
293294 pb. push ( "publish" ) ;
294295 pb. push ( "enum" ) ;
295296 let folder = pb. to_str ( ) . unwrap ( ) ;
296- let file = file_creator ( folder, & enum_name, EXTENSION , false ) ;
297+ let file = file_creator ( folder, & enum_name, EXTENSION , false , false ) ;
297298 if let Ok ( file) = file {
298299 let mut reader = BufReader :: new ( & file) ;
299300 let mut string = String :: new ( ) ;
@@ -441,14 +442,17 @@ pub(crate) fn compare_enum_cache(
441442 }
442443 }
443444 let next_cache_toml = toml:: to_string ( & next_cache) . unwrap ( ) ;
444- let mut file = file_creator ( "enum" , & enum_name, EXTENSION , true ) . unwrap ( ) ;
445- file. write_all ( next_cache_toml. as_bytes ( ) )
446- . unwrap_or_else ( |_| {
447- panic ! (
448- "[CompatibilityEnumCheck] {:?}.{:?}: write cache error" ,
449- enum_name, EXTENSION
450- )
451- } ) ;
445+ if !cfg ! ( feature = "skip_compare_cache" ) {
446+ let mut file = file_creator ( "enum" , & enum_name, EXTENSION , true , true ) . unwrap ( ) ;
447+ file. write_all ( next_cache_toml. as_bytes ( ) )
448+ . unwrap_or_else ( |_| {
449+ panic ! (
450+ "[CompatibilityEnumCheck] {:?}.{:?}: write cache error" ,
451+ enum_name, EXTENSION
452+ )
453+ } ) ;
454+ }
455+
452456 Ok ( token)
453457}
454458
@@ -503,7 +507,7 @@ pub(crate) fn compare_struct_cache(
503507 pb. push ( "publish" ) ;
504508 pb. push ( "struct" ) ;
505509 let folder = pb. to_str ( ) . unwrap ( ) ;
506- let file = file_creator ( folder, & struct_name, EXTENSION , false ) ;
510+ let file = file_creator ( folder, & struct_name, EXTENSION , false , false ) ;
507511 if let Ok ( file) = file {
508512 let mut reader = BufReader :: new ( & file) ;
509513 let mut string = String :: new ( ) ;
@@ -542,14 +546,16 @@ pub(crate) fn compare_struct_cache(
542546 }
543547 }
544548 let next_cache_toml = toml:: to_string ( & next_cache) . unwrap ( ) ;
545- let mut file = file_creator ( "struct" , & struct_name, EXTENSION , true ) . unwrap ( ) ;
546- file. write_all ( next_cache_toml. as_bytes ( ) )
547- . unwrap_or_else ( |_| {
548- panic ! (
549- "[CompatibilityStructCheck] {:?}.{:?}: write cache error" ,
550- struct_name, EXTENSION
551- )
552- } ) ;
549+ if !cfg ! ( feature = "skip_compare_cache" ) {
550+ let mut file = file_creator ( "struct" , & struct_name, EXTENSION , true , true ) . unwrap ( ) ;
551+ file. write_all ( next_cache_toml. as_bytes ( ) )
552+ . unwrap_or_else ( |_| {
553+ panic ! (
554+ "[CompatibilityStructCheck] {:?}.{:?}: write cache error" ,
555+ struct_name, EXTENSION
556+ )
557+ } ) ;
558+ }
553559 Ok ( token)
554560}
555561
0 commit comments