Skip to content

Commit 1ba3e04

Browse files
nyuwareqkaiser
authored andcommitted
fix(cpio): Fix dupplicated CPIO entries by overwriting them.
1 parent 00de4c4 commit 1ba3e04

File tree

8 files changed

+22
-1
lines changed

8 files changed

+22
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:fab950a545cff6286c14c8736f532a1204c217de2e1a32f66e83655c7196a7ab
3+
size 1024
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:a0bee6616b5e5eae6799cb4525a884a82e7161614f11122bbdf4383b2ac05998
3+
size 5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:b946a10c9133c481c9c95234cb8d61a5c063388721f22021ff30363e1bfaa3b0
3+
size 13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:6afd32ccf0462f3660d9fe54596a8c519d9478619c9798bc56bec0ba3ac1a7a3
3+
size 15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
purple.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:596157e5858a0c647af6a4f55945b9c09ed70dc3f5d0e3db248ea5d5136e8ad3
3+
size 7

unblob/file_utils.py

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

629629
def unlink(self, path):
630630
"""Delete file within extraction path."""
631-
logger.debug("unlink file", file_path=path)
631+
logger.debug("unlink file", file_path=path, _verbosity=3)
632632
safe_path = self._get_extraction_path(path, "unlink")
633633

634634
safe_path.unlink(missing_ok=True)

unblob/handlers/archive/cpio.py

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ def dump_entries(self, fs: FileSystem):
210210
if entry.path.name in ("", "."):
211211
continue
212212

213+
# There are cases where CPIO archives have duplicated entries
214+
# We then unlink the files to overwrite them and avoid an error.
215+
if not stat.S_ISDIR(entry.mode):
216+
fs.unlink(entry.path)
217+
213218
if stat.S_ISREG(entry.mode):
214219
fs.carve(entry.path, self.file, entry.start_offset, entry.size)
215220
elif stat.S_ISDIR(entry.mode):

0 commit comments

Comments
 (0)