Skip to content

Commit 391c363

Browse files
feedback
1 parent b26bda4 commit 391c363

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
250250
.into_iter()
251251
.filter_map(Result::ok)
252252
.filter(|entry| entry.path().is_file())
253-
.map(|entry| Ok(entry.into_path()))
254-
.collect::<Result<Vec<_>>>()?
255-
.into_iter()
253+
.map(|entry| entry.into_path())
256254
.sorted_by(|a, b| a.cmp(b));
257255

258256
// Need to set the last modified time to a fixed value to ensure consistent checksums
@@ -400,3 +398,27 @@ fn poll_assemble(
400398

401399
Ok(())
402400
}
401+
402+
#[cfg(test)]
403+
mod tests {
404+
use super::*;
405+
use std::fs;
406+
use zip::ZipArchive;
407+
408+
#[test]
409+
fn test_normalize_directory_preserves_top_level_directory_name() -> Result<()> {
410+
let temp_dir = crate::utils::fs::TempDir::create()?;
411+
let test_dir = temp_dir.path().join("MyApp.xcarchive");
412+
fs::create_dir_all(&test_dir.join("Products"))?;
413+
fs::write(test_dir.join("Products").join("app.txt"), "test content")?;
414+
415+
let result_zip = normalize_directory(&test_dir)?;
416+
let zip_file = fs::File::open(result_zip.path())?;
417+
let mut archive = ZipArchive::new(zip_file)?;
418+
let file = archive.by_index(0)?;
419+
let file_path = file.name();
420+
421+
assert_eq!(file_path, "MyApp.xcarchive/Products/app.txt");
422+
Ok(())
423+
}
424+
}

0 commit comments

Comments
 (0)