Skip to content

Commit

Permalink
fix: deep_copy_file no longer allows overwriting an existing file, …
Browse files Browse the repository at this point in the history
…to match the behavior of `shallow_copy_file`
  • Loading branch information
Pr0methean committed Jun 17, 2024
1 parent 8d78fd9 commit 6f12022
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ impl<A: Read + Write + Seek> ZipWriter<A> {
/// widely-compatible archive compared to [Self::shallow_copy_file]. Does not copy alignment.
pub fn deep_copy_file(&mut self, src_name: &str, dest_name: &str) -> ZipResult<()> {
self.finish_file()?;
if src_name == dest_name {
return Err(InvalidArchive("Trying to copy a file to itself"));
if src_name == dest_name || self.files.contains_key(dest_name) {
return Err(InvalidArchive("That file already exists"));
}
let write_position = self.inner.get_plain().stream_position()?;
let src_index = self.index_by_name(src_name)?;
Expand Down

0 comments on commit 6f12022

Please sign in to comment.