Skip to content

Commit 8ce9577

Browse files
fix(launchpad): Ensure mobile artifact's zip structures are preserved (#2585)
WIthout this, the code would remove the xcarchive wrapper directory, which causes issues when trying to parse the artifact in launchpad
1 parent 270c6e3 commit 8ce9577

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
252252
.filter(|entry| entry.path().is_file())
253253
.map(|entry| {
254254
let entry_path = entry.into_path();
255-
let relative_path = entry_path.strip_prefix(path)?.to_owned();
255+
let relative_path = entry_path.strip_prefix(
256+
path.parent().ok_or_else(|| anyhow!("Cannot determine parent directory for path: {}", path.display()))?
257+
)?.to_owned();
256258
Ok((entry_path, relative_path))
257259
})
258260
.collect::<Result<Vec<_>>>()?
@@ -401,3 +403,27 @@ fn poll_assemble(
401403

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

0 commit comments

Comments
 (0)