From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 14B6B158042 for ; Fri, 1 Nov 2024 23:42:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 40ED2E086A; Fri, 1 Nov 2024 23:42:08 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 229FEE086A for ; Fri, 1 Nov 2024 23:42:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2F06C3430AB for ; Fri, 1 Nov 2024 23:42:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BD6A01295 for ; Fri, 1 Nov 2024 23:42:05 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1730504010.5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: /, lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: NEWS lib/portage/gpkg.py X-VCS-Directories: / lib/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35 X-VCS-Branch: master Date: Fri, 1 Nov 2024 23:42:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 368ff551-a2a3-4a74-b31a-ce6bc2412dc7 X-Archives-Hash: 4b99e930cd8ad15de69c4da7a3ed454d commit: 5eaf9f2e491ae9c6f54d77c821b46b2cb5af3f35 Author: Etienne Buira free fr> AuthorDate: Fri Nov 1 23:33:30 2024 +0000 Commit: Zac Medico gentoo 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 free.fr> Bug: https://bugs.gentoo.org/942512 Signed-off-by: Zac Medico 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