1
Fork 0

Make sure all input archives are unmapped before persisting the output archive

This commit is contained in:
bjorn3 2022-12-03 12:53:47 +00:00
parent e1edc13afb
commit a99838a115

View file

@ -290,11 +290,17 @@ impl<'a> ArArchiveBuilder<'a> {
false, false,
)?; )?;
let any_entries = !entries.is_empty();
drop(entries);
// Drop src_archives to unmap all input archives, which is necessary if we want to write the
// output archive to the same location as an input archive on Windows.
drop(self.src_archives);
archive_tmpfile archive_tmpfile
.persist(output) .persist(output)
.map_err(|err| io_error_context("failed to rename archive file", err.error))?; .map_err(|err| io_error_context("failed to rename archive file", err.error))?;
Ok(!entries.is_empty()) Ok(any_entries)
} }
} }