Skip to content

Commit c2a5c76

Browse files
committed
fix(cpio): Fix dupplicated CPIO entries by overwriting them.
1 parent 0dc4bb5 commit c2a5c76

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

unblob/file_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def open( # noqa: A003
621621

622622
def unlink(self, path):
623623
"""Delete file within extraction path."""
624-
logger.debug("unlink file", file_path=path)
624+
logger.debug("unlink file", file_path=path, _verbosity=3)
625625
safe_path = self._get_extraction_path(path, "unlink")
626626

627627
safe_path.unlink(missing_ok=True)

unblob/handlers/archive/cpio.py

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def dump_entries(self, fs: FileSystem):
211211
continue
212212

213213
if stat.S_ISREG(entry.mode):
214+
fs.unlink(entry.path)
214215
fs.carve(entry.path, self.file, entry.start_offset, entry.size)
215216
elif stat.S_ISDIR(entry.mode):
216217
fs.mkdir(
@@ -222,6 +223,7 @@ def dump_entries(self, fs: FileSystem):
222223
self.file[entry.start_offset : entry.start_offset + entry.size]
223224
).decode("utf-8")
224225
)
226+
fs.unlink(entry.path)
225227
fs.create_symlink(src=link_path, dst=entry.path)
226228
elif (
227229
stat.S_ISCHR(entry.mode)

0 commit comments

Comments
 (0)