Skip to content

Commit 7a4cc1a

Browse files
feedback
1 parent 6991773 commit 7a4cc1a

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
@@ -249,9 +249,7 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
249249
.into_iter()
250250
.filter_map(Result::ok)
251251
.filter(|entry| entry.path().is_file())
252-
.map(|entry| Ok(entry.into_path()))
253-
.collect::<Result<Vec<_>>>()?
254-
.into_iter()
252+
.map(|entry| entry.into_path())
255253
.sorted_by(|a, b| a.cmp(b));
256254

257255
// Need to set the last modified time to a fixed value to ensure consistent checksums
@@ -401,3 +399,27 @@ fn poll_assemble(
401399

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

0 commit comments

Comments
 (0)