diff --git a/unblob/file_utils.py b/unblob/file_utils.py index 21e887b487..31c202033b 100644 --- a/unblob/file_utils.py +++ b/unblob/file_utils.py @@ -621,7 +621,7 @@ def open( # noqa: A003 def unlink(self, path): """Delete file within extraction path.""" - logger.debug("unlink file", file_path=path) + logger.debug("unlink file", file_path=path, _verbosity=3) safe_path = self._get_extraction_path(path, "unlink") safe_path.unlink(missing_ok=True) diff --git a/unblob/handlers/archive/cpio.py b/unblob/handlers/archive/cpio.py index 43dc2836a4..d1c40f5eb6 100644 --- a/unblob/handlers/archive/cpio.py +++ b/unblob/handlers/archive/cpio.py @@ -211,6 +211,7 @@ def dump_entries(self, fs: FileSystem): continue if stat.S_ISREG(entry.mode): + fs.unlink(entry.path) fs.carve(entry.path, self.file, entry.start_offset, entry.size) elif stat.S_ISDIR(entry.mode): fs.mkdir( @@ -222,6 +223,7 @@ def dump_entries(self, fs: FileSystem): self.file[entry.start_offset : entry.start_offset + entry.size] ).decode("utf-8") ) + fs.unlink(entry.path) fs.create_symlink(src=link_path, dst=entry.path) elif ( stat.S_ISCHR(entry.mode)