Skip to content

Commit 16246a6

Browse files
address feedback
1 parent c5d1cf3 commit 16246a6

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,10 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
256256
.into_iter()
257257
.filter_map(Result::ok)
258258
.filter(|entry| entry.path().is_file())
259-
.map(|entry| {
260-
let entry_path = entry.into_path();
261-
let relative_path = entry_path.strip_prefix(path)?.to_owned();
262-
// Preserve the directory structure by including the directory name
263-
let full_relative_path = Path::new(dir_name).join(relative_path);
264-
Ok((entry_path, full_relative_path))
265-
})
259+
.map(|entry| Ok(entry.into_path()))
266260
.collect::<Result<Vec<_>>>()?
267261
.into_iter()
268-
.sorted_by(|(_, a), (_, b)| a.cmp(b));
262+
.sorted_by(|a, b| a.cmp(b));
269263

270264
// Need to set the last modified time to a fixed value to ensure consistent checksums
271265
// This is important as an optimization to avoid re-uploading the same chunks if they're already on the server
@@ -274,10 +268,12 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
274268
.compression_method(zip::CompressionMethod::Stored)
275269
.last_modified_time(DateTime::default());
276270

277-
for (entry_path, relative_path) in entries {
278-
debug!("Adding file to zip: {}", relative_path.display());
271+
for entry_path in entries {
272+
let relative_path = entry_path.strip_prefix(path)?.to_owned();
273+
let full_relative_path = Path::new(dir_name).join(relative_path);
274+
debug!("Adding file to zip: {}", full_relative_path.display());
279275

280-
zip.start_file(relative_path.to_string_lossy(), options)?;
276+
zip.start_file(full_relative_path.to_string_lossy(), options)?;
281277
let file_byteview = ByteView::open(&entry_path)?;
282278
zip.write_all(file_byteview.as_slice())?;
283279
file_count += 1;

0 commit comments

Comments
 (0)