Skip to content

Commit 579d92d

Browse files
committed
improve symlink/hardlink handling
Signed-off-by: Zen <[email protected]>
1 parent 83c2d3a commit 579d92d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/pycpio/cpio/archive.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@loggify
1010
class CPIOArchive(dict):
1111
from .data import CPIOData
12+
from .symlink import CPIO_Symlink
1213
from pycpio.header import HEADER_NEW
1314

1415
def __setitem__(self, name, value):
@@ -38,7 +39,7 @@ def __setitem__(self, name, value):
3839
self.inodes[value.header.ino] = [name]
3940

4041
# Check if the hash already exists and the data is not empty
41-
if value.hash in self.hashes and value.data != b'':
42+
if value.hash in self.hashes and value.data != b'' and not isinstance(value, CPIO_Symlink):
4243
match = self[self.hashes[value.hash]]
4344
self.logger.warning("[%s] Hash matches existing entry: %s" % (value.header.name, match.header.name))
4445
value.header.ino = match.header.ino

src/pycpio/pycpio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def read_cpio_file(self, file_path: Path):
5555
reader = CPIOReader(**kwargs)
5656
self.entries.update(reader.entries)
5757

58-
def write_cpio_file(self, file_path: Union[Path, str]):
58+
def write_cpio_file(self, file_path: Union[Path, str], *args, **kwargs):
5959
""" Writes a CPIO archive to file. """
60-
kwargs = {'structure': self.structure,
61-
'_log_init': False, 'logger': self.logger}
60+
kwargs.update({'structure': self.structure,
61+
'_log_init': False, 'logger': self.logger})
6262
writer = CPIOWriter(self.entries, file_path, **kwargs)
6363
writer.write()
6464

0 commit comments

Comments
 (0)