Skip to content

Commit 31dcbc0

Browse files
committed
fix(cpio): Fix dupplicated CPIO entries by overwriting them.
1 parent ce75c84 commit 31dcbc0

File tree

7 files changed

+19
-1
lines changed

7 files changed

+19
-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:680e5a70389cde3c851563f81cbfc02be2d2460ac20765246d472f1d4b3bf24a
3+
size 512
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 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:6ace33171ce0acb6891e3cc311d75a97aa429d77c05cba600d49ed9652ed49de
3+
size 4

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)