Skip to content

Commit b26bda4

Browse files
further simplify
1 parent dbd4d5d commit b26bda4

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,6 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
242242

243243
let mut file_count = 0;
244244

245-
// Get the directory name to preserve in the zip structure
246-
let dir_name = path
247-
.file_name()
248-
.ok_or_else(|| anyhow!("Failed to get directory name"))?
249-
.to_str()
250-
.ok_or_else(|| anyhow!("Directory name is not valid UTF-8"))?;
251-
252245
// Collect and sort entries for deterministic ordering
253246
// This is important to ensure stable sha1 checksums for the zip file as
254247
// an optimization is used to avoid re-uploading the same chunks if they're already on the server.
@@ -270,11 +263,12 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
270263
.last_modified_time(DateTime::default());
271264

272265
for entry_path in entries {
273-
let relative_path = entry_path.strip_prefix(path)?.to_owned();
274-
let full_relative_path = Path::new(dir_name).join(relative_path);
275-
debug!("Adding file to zip: {}", full_relative_path.display());
266+
let zip_path = entry_path.strip_prefix(
267+
path.parent().ok_or_else(|| anyhow!("Failed to get parent directory"))?
268+
)?.to_owned();
269+
debug!("Adding file to zip: {}", zip_path.display());
276270

277-
zip.start_file(full_relative_path.to_string_lossy(), options)?;
271+
zip.start_file(zip_path.to_string_lossy(), options)?;
278272
let file_byteview = ByteView::open(&entry_path)?;
279273
zip.write_all(file_byteview.as_slice())?;
280274
file_count += 1;

0 commit comments

Comments
 (0)