From 2b4328380f1f352f81a5014764dbe21dfbd821d0 Mon Sep 17 00:00:00 2001 From: Andrea Nardelli Date: Fri, 15 Nov 2024 15:49:05 +0100 Subject: [PATCH 1/3] `tar_writer.py`: address duplicate dir warning regression --- pkg/private/tar/tar_writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py index 06d0cad6..af4f6b10 100644 --- a/pkg/private/tar/tar_writer.py +++ b/pkg/private/tar/tar_writer.py @@ -129,7 +129,7 @@ def _addfile(self, info, fileobj=None): # Enforce the ending / for directories so we correctly deduplicate. if not info.name.endswith('/'): info.name += '/' - if not self.allow_dups_from_deps and self._have_added(info.name): + elif not self.allow_dups_from_deps and self._have_added(info.name): print('Duplicate file in archive: %s, ' 'picking first occurrence' % info.name) return From 19a742152bb59f72fab351ac9266578ef50a14a2 Mon Sep 17 00:00:00 2001 From: Andrea Nardelli Date: Mon, 18 Nov 2024 09:09:30 +0100 Subject: [PATCH 2/3] `tar_writer.py`: comment dir dup check --- pkg/private/tar/tar_writer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py index af4f6b10..e71b624e 100644 --- a/pkg/private/tar/tar_writer.py +++ b/pkg/private/tar/tar_writer.py @@ -129,10 +129,12 @@ def _addfile(self, info, fileobj=None): # Enforce the ending / for directories so we correctly deduplicate. if not info.name.endswith('/'): info.name += '/' + # Directories with different contents should get merged + # without warnings, warn about duplicate *files* only elif not self.allow_dups_from_deps and self._have_added(info.name): - print('Duplicate file in archive: %s, ' - 'picking first occurrence' % info.name) - return + print('Duplicate file in archive: %s, ' + 'picking first occurrence' % info.name) + return self.tar.addfile(info, fileobj) self.members.add(info.name) From 9e0a63f497e1d5179a3ef1bffe0e6c70de83c349 Mon Sep 17 00:00:00 2001 From: Andrea Nardelli Date: Mon, 18 Nov 2024 17:12:10 +0100 Subject: [PATCH 3/3] `tar_writer.py`: omit warning for duplicate dirs --- pkg/private/tar/tar_writer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py index e71b624e..756fcea4 100644 --- a/pkg/private/tar/tar_writer.py +++ b/pkg/private/tar/tar_writer.py @@ -129,11 +129,12 @@ def _addfile(self, info, fileobj=None): # Enforce the ending / for directories so we correctly deduplicate. if not info.name.endswith('/'): info.name += '/' - # Directories with different contents should get merged - # without warnings, warn about duplicate *files* only - elif not self.allow_dups_from_deps and self._have_added(info.name): - print('Duplicate file in archive: %s, ' - 'picking first occurrence' % info.name) + if not self.allow_dups_from_deps and self._have_added(info.name): + # Directories with different contents should get merged without warnings. + # If they have overlapping content, the warning will be on their duplicate *files* instead + if info.type != tarfile.DIRTYPE: + print('Duplicate file in archive: %s, ' + 'picking first occurrence' % info.name) return self.tar.addfile(info, fileobj)