From bb5bc15b1ed6d9ec0afe0c04a1e2536c32272a9b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 25 Sep 2006 22:53:24 +0000 Subject: [PATCH] For bug #80846, prevent false collisions caused by symlinks. Thanks to Thomas Bettler for the initial patch. This patch is from trunk r4431. svn path=/main/branches/2.1.1/; revision=4537 --- pym/portage.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pym/portage.py b/pym/portage.py index 6739e91fb..9e46cb4d3 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -5559,6 +5559,7 @@ class dblink: self.updateprotect = protect_obj.updateprotect self.isprotected = protect_obj.isprotected self.contentscache=[] + self._contents_inodes = None def lockdb(self): if self.lock_num == 0: @@ -5840,11 +5841,25 @@ class dblink: (for this or a previous version)""" destfile = normalize_path( os.path.join(destroot, filename.lstrip(os.path.sep))) - if not os.path.exists(destfile): + try: + mylstat = os.lstat(destfile) + except OSError: return True + pkgfiles = self.getcontents() if pkgfiles and filename in pkgfiles: return True + if pkgfiles: + if self._contents_inodes is None: + self._contents_inodes = set() + for x in pkgfiles: + try: + lstat = os.lstat(x) + self._contents_inodes.add((lstat.st_dev, lstat.st_ino)) + except OSError: + pass + if (mylstat.st_dev, mylstat.st_ino) in self._contents_inodes: + return True return False -- 2.26.2