Bug fix
This commit is contained in:
parent
c4f91c2895
commit
d23f036955
1 changed files with 9 additions and 7 deletions
16
src/write.rs
16
src/write.rs
|
@ -801,13 +801,15 @@ impl<W: Write + Seek> ZipWriter<W> {
|
||||||
self.switch_to_non_encrypting_writer()?;
|
self.switch_to_non_encrypting_writer()?;
|
||||||
// Make sure this is the last file, and that no shallow copies of it remain; otherwise we'd
|
// Make sure this is the last file, and that no shallow copies of it remain; otherwise we'd
|
||||||
// overwrite a valid file and corrupt the archive
|
// overwrite a valid file and corrupt the archive
|
||||||
let last_file_start = last_file.data_start.get().unwrap();
|
let rewind_safe: bool = match last_file.data_start.get() {
|
||||||
if self
|
None => self.files.is_empty(),
|
||||||
.files
|
Some(last_file_start) => self.files.iter().all(|file| {
|
||||||
.iter()
|
file.data_start
|
||||||
.flat_map(|file| file.data_start.get())
|
.get()
|
||||||
.all(|start| start < last_file_start)
|
.is_some_and(|start| start < last_file_start)
|
||||||
{
|
}),
|
||||||
|
};
|
||||||
|
if rewind_safe {
|
||||||
self.inner
|
self.inner
|
||||||
.get_plain()
|
.get_plain()
|
||||||
.seek(SeekFrom::Start(last_file.header_start))?;
|
.seek(SeekFrom::Start(last_file.header_start))?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue