diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-04-13 07:32:46 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-04-13 07:32:46 +0000 |
commit | a8776a5df44d20a26db156f6803172917df5f1ad (patch) | |
tree | 8aefbbf01d3108d4d08f9029854cc2d71e6dba6c | |
parent | 231f3ec509e4c234aee5ae95385e3c9d2f458e98 (diff) | |
download | portage-a8776a5df44d20a26db156f6803172917df5f1ad.tar.gz portage-a8776a5df44d20a26db156f6803172917df5f1ad.tar.bz2 portage-a8776a5df44d20a26db156f6803172917df5f1ad.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.
svn path=/main/trunk/; revision=9864
-rw-r--r-- | pym/portage/__init__.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 92cacf76e..6a6d088d7 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -5211,11 +5211,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 = 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 |