From a57e6c5b87b00435a20fbcd74f09689482913d26 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 30 Apr 2009 07:12:41 +0000 Subject: [PATCH] =?utf8?q?Bug=20#266211=20-=20Handle=20ESTALE=20like=20ENO?= =?utf8?q?ENT=20in=20fetch=20and=20locking=20code.=20Thanks=20to=20Krzyszt?= =?utf8?q?of=20Ol=C4=99dzki=20=20for=20the=20initial=20?= =?utf8?q?patch.=20(trunk=20r13347)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/main/branches/2.1.6/; revision=13503 --- pym/portage/__init__.py | 17 +++++++++-------- pym/portage/locks.py | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 3dada6797..fba07547f 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3914,7 +3914,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 @@ -4026,7 +4026,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) @@ -4041,14 +4041,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: @@ -4192,7 +4192,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 @@ -4216,7 +4216,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 @@ -4228,7 +4228,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 @@ -4282,7 +4283,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 diff --git a/pym/portage/locks.py b/pym/portage/locks.py index 36bc085bf..05a65644f 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -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 -- 2.26.2