Skip to content

Commit 501ff90

Browse files
ref: Clean up code
It is a bit weird to have this block defining two variables inside the definition of another variable. I think the following is a bit more readable. It also keeps the code DRY.
1 parent c6d075d commit 501ff90

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,21 +276,13 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
276276
// Need to set the last modified time to a fixed value to ensure consistent checksums
277277
// This is important as an optimization to avoid re-uploading the same chunks if they're already on the server
278278
// but the last modified time being different will cause checksums to be different.
279-
#[cfg(not(windows))]
280-
let options = {
281-
let metadata = fs::metadata(&entry_path)?;
282-
let mode = metadata.permissions().mode();
283-
SimpleFileOptions::default()
284-
.compression_method(zip::CompressionMethod::Stored)
285-
.last_modified_time(DateTime::default())
286-
.unix_permissions(mode)
287-
};
288-
289-
#[cfg(windows)]
290279
let options = SimpleFileOptions::default()
291280
.compression_method(zip::CompressionMethod::Stored)
292281
.last_modified_time(DateTime::default());
293282

283+
#[cfg(not(windows))]
284+
let options = options.unix_permissions(fs::metadata(&entry_path)?.permissions().mode());
285+
294286
zip.start_file(relative_path.to_string_lossy(), options)?;
295287
let file_byteview = ByteView::open(&entry_path)?;
296288
zip.write_all(file_byteview.as_slice())?;

0 commit comments

Comments
 (0)