summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-13 22:07:18 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-13 22:07:18 +0000
commit2d4130c3d731cea2e67a46beff8dc63ed73f2d02 (patch)
tree849a4b46a8d0752250da6d96c6d695a2f03982ed /pym
parentabe4f65bbf1790bdc69722811cf03051f9f2759a (diff)
downloadportage-2d4130c3d731cea2e67a46beff8dc63ed73f2d02.tar.gz
portage-2d4130c3d731cea2e67a46beff8dc63ed73f2d02.tar.bz2
portage-2d4130c3d731cea2e67a46beff8dc63ed73f2d02.zip
Make movefile() tolerant to EPERM errors that can be raised from utime()
calls. Instead of failing, use stat() to return the mtime if possible. (trunk r9863:9865) svn path=/main/branches/2.1.2/; revision=9875
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 8b0c123e5..482ab8ff2 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -5208,11 +5208,22 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
print "!!!",e
return None
- if newmtime:
- os.utime(dest,(newmtime,newmtime))
- else:
- os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
- newmtime=sstat[stat.ST_MTIME]
+ try:
+ if newmtime is not None:
+ os.utime(dest, (newmtime, newmtime))
+ else:
+ os.utime(dest, (sstat.st_atime, sstat.st_mtime))
+ newmtime = long(sstat.st_mtime)
+ except OSError:
+ # The utime can fail here with EPERM even though the move succeeded.
+ # Instead of failing, use stat to return the mtime if possible.
+ try:
+ newmtime = long(os.stat(dest).st_mtime)
+ except OSError, e:
+ writemsg("!!! Failed to stat in movefile()\n", noiselevel=-1)
+ writemsg("!!! %s\n" % dest, noiselevel=-1)
+ writemsg("!!! %s\n" % str(e), noiselevel=-1)
+ return None
if bsd_chflags:
# Restore the flags we saved before moving