diff --git a/src/write.rs b/src/write.rs index 729d9395..9f56c77f 100644 --- a/src/write.rs +++ b/src/write.rs @@ -467,6 +467,9 @@ impl ZipWriter { } fn finish_file(&mut self) -> ZipResult<()> { + if !self.writing_to_file { + return Ok(()); + } if self.writing_to_extra_field { // Implicitly calling [`ZipWriter::end_extra_data`] for empty files. self.end_extra_data()?;