commit:     35b5e4d71ebb5c7408dba7dc27cff0c22cad1562
Author:     gcarq <egger.m <AT> protonmail <DOT> com>
AuthorDate: Mon Mar 27 13:31:44 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue May 23 00:22:09 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=35b5e4d7

mergeme: Rely on mydmode instead of calling os.path.exists again

Signed-off-by: gcarq <egger.m <AT> protonmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dbapi/vartree.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 317cf327a..676d4aa05 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -5544,6 +5544,8 @@ class dblink:
                     destmd5,
                     mydest_link,
                 )
+                if protected and moveme:
+                    mydmode = None
 
             zing = "!!!"
             if not moveme:
@@ -5584,6 +5586,7 @@ class dblink:
                         msg.append("")
                         self._eerror("preinst", msg)
                         mydest = newdest
+                        mydmode = None
 
                 # if secondhand is None it means we're operating in "force" 
mode and should not create a second hand.
                 if (secondhand is not None) and (not os.path.exists(myrealto)):
@@ -5797,6 +5800,7 @@ class dblink:
                     msg.append("")
                     self._eerror("preinst", msg)
                     mydest = newdest
+                    mydmode = None
 
                 # whether config protection or not, we merge the new file the
                 # same way.  Unless moveme=0 (blocking directory)
@@ -6260,10 +6264,7 @@ class dblink:
         Takes file mode and extended attributes into account.
         Should only be used for regular files.
         """
-        if not os.path.exists(mydest):
-            return True
-
-        if mymode != mydmode:
+        if mydmode is None or not stat.S_ISREG(mydmode) or mymode != mydmode:
             return True
 
         excluded_xattrs = self.settings.get("PORTAGE_XATTR_EXCLUDE", "")

Reply via email to