Skip to content

Commit 3b31c33

Browse files
fix: Use orig_path for bundle sources output file name (#2514)
For dSYMs, `canonical_path` excludes the original dSYM extension, causing any extension before the `.dSYM` to be lost when adding the `.src.zip` extension. This caused the bug observed in #2502. Instead, we should use the file name given in the original path when generating the file name for the output source bundle. Fixes #2502
1 parent 5a7159e commit 3b31c33

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/commands/debug_files/bundle_sources.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
7171
let output_path = matches.get_one::<String>("output").map(Path::new);
7272

7373
for orig_path in matches.get_many::<String>("paths").unwrap() {
74+
let orig_path: &Path = orig_path.as_ref();
7475
let canonical_path = get_canonical_path(orig_path)?;
7576

7677
let archive = match DifFile::open_path(&canonical_path, None)? {
7778
DifFile::Archive(archive) => archive,
7879
_ => {
79-
warn!("Cannot build source bundles from {}", orig_path);
80+
warn!("Cannot build source bundles from {}", orig_path.display());
8081
continue;
8182
}
8283
};
@@ -88,7 +89,11 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
8889
for (index, object) in archive.get().objects().enumerate() {
8990
let object = object?;
9091

91-
let mut out = output_path.unwrap_or(parent_path).join(filename);
92+
let mut out = output_path.unwrap_or(parent_path).join(
93+
orig_path
94+
.file_name()
95+
.expect("orig_path should have a file name"),
96+
);
9297
match index {
9398
0 => out.set_extension("src.zip"),
9499
index => out.set_extension(format!("{index}.src.zip")),
@@ -109,7 +114,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
109114
)?;
110115

111116
if !written {
112-
eprintln!("skipped {orig_path} (no files found)");
117+
eprintln!("skipped {} (no files found)", orig_path.display());
113118
fs::remove_file(&out)?;
114119
continue;
115120
} else {

0 commit comments

Comments
 (0)