11use std:: borrow:: Cow ;
22use std:: io:: Write ;
33use std:: path:: Path ;
4+ #[ cfg( not( windows) ) ]
45use std:: fs;
6+ #[ cfg( not( windows) ) ]
7+ use std:: os:: unix:: fs:: PermissionsExt ;
58
69use anyhow:: { anyhow, bail, Context as _, Result } ;
710use clap:: { Arg , ArgAction , ArgMatches , Command } ;
@@ -13,9 +16,6 @@ use symbolic::common::ByteView;
1316use zip:: write:: SimpleFileOptions ;
1417use zip:: { DateTime , ZipWriter } ;
1518
16- #[ cfg( not( windows) ) ]
17- use std:: os:: unix:: fs:: PermissionsExt ;
18-
1919use crate :: api:: { Api , AuthenticatedApi , ChunkUploadCapability } ;
2020use crate :: config:: Config ;
2121use crate :: utils:: args:: ArgExt ;
@@ -268,22 +268,23 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
268268 for ( entry_path, relative_path) in entries {
269269 debug ! ( "Adding file to zip: {}" , relative_path. display( ) ) ;
270270
271- // Get file metadata to preserve permissions
272- let metadata = fs:: metadata ( & entry_path) ?;
273-
274271 // Need to set the last modified time to a fixed value to ensure consistent checksums
275272 // This is important as an optimization to avoid re-uploading the same chunks if they're already on the server
276273 // 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
282274 #[ cfg( not( windows) ) ]
283- {
275+ let options = {
276+ let metadata = fs:: metadata ( & entry_path) ?;
284277 let mode = metadata. permissions ( ) . mode ( ) ;
285- options = options. unix_permissions ( mode) ;
286- }
278+ SimpleFileOptions :: default ( )
279+ . compression_method ( zip:: CompressionMethod :: Stored )
280+ . last_modified_time ( DateTime :: default ( ) )
281+ . unix_permissions ( mode)
282+ } ;
283+
284+ #[ cfg( windows) ]
285+ let options = SimpleFileOptions :: default ( )
286+ . compression_method ( zip:: CompressionMethod :: Stored )
287+ . last_modified_time ( DateTime :: default ( ) ) ;
287288
288289 zip. start_file ( relative_path. to_string_lossy ( ) , options) ?;
289290 let file_byteview = ByteView :: open ( & entry_path) ?;
0 commit comments