Bug #266211 - Handle ESTALE like ENOENT in fetch and locking code. Thanks to
authorZac Medico <zmedico@gentoo.org>
Wed, 15 Apr 2009 18:43:23 +0000 (18:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 15 Apr 2009 18:43:23 +0000 (18:43 -0000)
Krzysztof Olędzki <ole+gentoo@ans.pl> for the initial patch.

svn path=/main/trunk/; revision=13347

pym/portage/__init__.py
pym/portage/locks.py

index 59f5410580d91c079e7b23241858cbba19bf4281..0b65570c0b0081e0413c6cbf8cc0a7b8b919cd60 100644 (file)
@@ -3924,7 +3924,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                try:
                                        mysize = os.stat(myfile_path).st_size
                                except OSError, e:
-                                       if e.errno != errno.ENOENT:
+                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                raise
                                        del e
                                        mysize = 0
@@ -4036,7 +4036,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                try:
                                                        os.unlink(myfile_path)
                                                except OSError, e:
-                                                       if e.errno != errno.ENOENT:
+                                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
                                                os.symlink(readonly_file, myfile_path)
@@ -4051,14 +4051,14 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                                " %(file)s\n" % {"file":myfile}))
                                                        break
                                                except (IOError, OSError), e:
-                                                       if e.errno != errno.ENOENT:
+                                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
 
                                try:
                                        mystat = os.stat(myfile_path)
                                except OSError, e:
-                                       if e.errno != errno.ENOENT:
+                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                raise
                                        del e
                                else:
@@ -4202,7 +4202,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                try:
                                                        mysize = os.stat(myfile_path).st_size
                                                except OSError, e:
-                                                       if e.errno != errno.ENOENT:
+                                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
                                                        mysize = 0
@@ -4226,7 +4226,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                try:
                                                        mystat = os.stat(myfile_path)
                                                except OSError, e:
-                                                       if e.errno != errno.ENOENT:
+                                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
                                                        fetched = 0
@@ -4238,7 +4238,8 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                                try:
                                                                        os.unlink(myfile_path)
                                                                except OSError, e:
-                                                                       if e.errno != errno.ENOENT:
+                                                                       if e.errno not in \
+                                                                               (errno.ENOENT, errno.ESTALE):
                                                                                raise
                                                                        del e
                                                                fetched = 0
@@ -4292,7 +4293,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                try:
                                                        mystat = os.stat(myfile_path)
                                                except OSError, e:
-                                                       if e.errno != errno.ENOENT:
+                                                       if e.errno not in (errno.ENOENT, errno.ESTALE):
                                                                raise
                                                        del e
                                                        fetched = 0
index 36bc085bf227b0efe4e00f2782b9b1c8e514ca90..05a65644fe806b04f46ecd22c03e32372321c598 100644 (file)
@@ -74,7 +74,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                                        if os.stat(lockfilename).st_gid != portage_gid:
                                                os.chown(lockfilename, -1, portage_gid)
                                except OSError, e:
-                                       if e.errno == errno.ENOENT: # No such file or directory
+                                       if e.errno in (errno.ENOENT, errno.ESTALE):
                                                return lockfile(mypath,
                                                        wantnewlockfile=wantnewlockfile,
                                                        unlinkfile=unlinkfile, waiting_msg=waiting_msg,
@@ -164,7 +164,7 @@ def _fstat_nlink(fd):
        try:
                return os.fstat(fd).st_nlink
        except EnvironmentError, e:
-               if e.errno == errno.ENOENT:
+               if e.errno in (errno.ENOENT, errno.ESTALE):
                        # Some filesystems such as CIFS return
                        # ENOENT which means st_nlink == 0.
                        return 0