commit: 5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35 Author: Etienne Buira <etienne.buira <AT> free <DOT> fr> AuthorDate: Fri Nov 1 23:33:30 2024 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Fri Nov 1 23:33:30 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5eaf9f2e
gpkg: do not consider symlinks targets for size estimation Symlinks size is already accounted for, so there is no need to account for the pointed to file. Moreover, previous code failed to handle permission error when using ROOT= and having absolute symlinks pointing to running root. Signed-off-by: Etienne Buira <etienne.buira <AT> free.fr> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> NEWS | 2 ++ lib/portage/gpkg.py | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index 5c1cea5c27..8847f02098 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ Bug fixes: * binarytree: Fix _inject_repo_revisions to ignore remote packages for which source repostories are missing, triggering KeyError (PR #1391). +* gpkg: do not consider symlinks targets for size estimation (bug #942512). + portage-3.0.66.1 (2024-09-18) -------------- diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py index 06e2283ce1..5f392e95e8 100644 --- a/lib/portage/gpkg.py +++ b/lib/portage/gpkg.py @@ -1960,14 +1960,10 @@ class gpkg: image_max_link_length = max(image_max_link_length, path_link_length) - try: - file_size = os.path.getsize(f) - except FileNotFoundError: - # Ignore file not found if symlink to non-existing file - if os.path.islink(f): - continue - else: - raise + if stat.S_ISLNK(file_stat.st_mode): + continue + + file_size = os.path.getsize(f) image_total_size += file_size image_max_file_size = max(image_max_file_size, file_size) @@ -2055,14 +2051,10 @@ class gpkg: image_max_link_length = max(image_max_link_length, path_link_length) if os.path.isfile(path): - try: - file_size = os.path.getsize(path) - except FileNotFoundError: - # Ignore file not found if symlink to non-existing file - if os.path.islink(path): - continue - else: - raise + if stat.S_ISLNK(file_stat.st_mode): + continue + + file_size = os.path.getsize(path) image_total_size += file_size if file_size > image_max_file_size: image_max_file_size = file_size
