Skip to content

Commit ac7dd77

Browse files
committed
Fix format
1 parent 794feec commit ac7dd77

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::borrow::Cow;
22
use std::io::Write;
33
use std::path::Path;
4+
#[cfg(not(windows))]
45
use std::fs;
6+
#[cfg(not(windows))]
7+
use std::os::unix::fs::PermissionsExt;
58

69
use anyhow::{anyhow, bail, Context as _, Result};
710
use clap::{Arg, ArgAction, ArgMatches, Command};
@@ -13,9 +16,6 @@ use symbolic::common::ByteView;
1316
use zip::write::SimpleFileOptions;
1417
use zip::{DateTime, ZipWriter};
1518

16-
#[cfg(not(windows))]
17-
use std::os::unix::fs::PermissionsExt;
18-
1919
use crate::api::{Api, AuthenticatedApi, ChunkUploadCapability};
2020
use crate::config::Config;
2121
use 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

Comments
 (0)