Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/commands/mobile_app/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
.filter(|entry| entry.path().is_file())
.map(|entry| {
let entry_path = entry.into_path();
let relative_path = entry_path.strip_prefix(path)?.to_owned();
let relative_path = entry_path.strip_prefix(
path.parent().ok_or_else(|| anyhow!("Cannot determine parent directory for path: {}", path.display()))?
)?.to_owned();
Ok((entry_path, relative_path))
})
.collect::<Result<Vec<_>>>()?
Expand Down Expand Up @@ -401,3 +403,27 @@ fn poll_assemble(

Ok(())
}

#[cfg(not(windows))]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not run on Windows?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit test just fails because instead of MyApp.xcarchive/Products/app.txt it's something like C:\\MyApp.xcarchive\\Products\\app.txt. Lets just skip

#[cfg(test)]
mod tests {
use super::*;
use std::fs;
use zip::ZipArchive;

#[test]
fn test_normalize_directory_preserves_top_level_directory_name() -> Result<()> {
let temp_dir = crate::utils::fs::TempDir::create()?;
let test_dir = temp_dir.path().join("MyApp.xcarchive");
fs::create_dir_all(test_dir.join("Products"))?;
fs::write(test_dir.join("Products").join("app.txt"), "test content")?;

let result_zip = normalize_directory(&test_dir)?;
let zip_file = fs::File::open(result_zip.path())?;
let mut archive = ZipArchive::new(zip_file)?;
let file = archive.by_index(0)?;
let file_path = file.name();
assert_eq!(file_path, "MyApp.xcarchive/Products/app.txt");
Ok(())
}
}