11use std:: borrow:: Cow ;
22use std:: io:: Write ;
33use std:: path:: Path ;
4- use std:: fs;
54
65use anyhow:: { anyhow, bail, Context as _, Result } ;
76use clap:: { Arg , ArgAction , ArgMatches , Command } ;
@@ -13,6 +12,8 @@ use symbolic::common::ByteView;
1312use zip:: write:: SimpleFileOptions ;
1413use zip:: { DateTime , ZipWriter } ;
1514
15+ #[ cfg( not( windows) ) ]
16+ use std:: fs;
1617#[ cfg( not( windows) ) ]
1718use std:: os:: unix:: fs:: PermissionsExt ;
1819
@@ -268,22 +269,23 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
268269 for ( entry_path, relative_path) in entries {
269270 debug ! ( "Adding file to zip: {}" , relative_path. display( ) ) ;
270271
271- // Get file metadata to preserve permissions
272- let metadata = fs:: metadata ( & entry_path) ?;
273-
274272 // Need to set the last modified time to a fixed value to ensure consistent checksums
275273 // This is important as an optimization to avoid re-uploading the same chunks if they're already on the server
276274 // but the last modified time being different will cause checksums to be different.
277- let mut options = SimpleFileOptions :: default ( )
278- . compression_method ( zip:: CompressionMethod :: Stored )
279- . last_modified_time ( DateTime :: default ( ) ) ;
280-
281- // Preserve Unix file permissions on non-Windows systems
282275 #[ cfg( not( windows) ) ]
283- {
276+ let options = {
277+ let metadata = fs:: metadata ( & entry_path) ?;
284278 let mode = metadata. permissions ( ) . mode ( ) ;
285- options = options. unix_permissions ( mode) ;
286- }
279+ SimpleFileOptions :: default ( )
280+ . compression_method ( zip:: CompressionMethod :: Stored )
281+ . last_modified_time ( DateTime :: default ( ) )
282+ . unix_permissions ( mode)
283+ } ;
284+
285+ #[ cfg( windows) ]
286+ let options = SimpleFileOptions :: default ( )
287+ . compression_method ( zip:: CompressionMethod :: Stored )
288+ . last_modified_time ( DateTime :: default ( ) ) ;
287289
288290 zip. start_file ( relative_path. to_string_lossy ( ) , options) ?;
289291 let file_byteview = ByteView :: open ( & entry_path) ?;
0 commit comments