From 1ad45f6820f9947da5719b900e9d5624ab355573 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sun, 13 Apr 2008 10:44:49 +0000 Subject: [PATCH] Merged from trunk 9862:9865 | 9864 | Make movefile() tolerant to EPERM errors that can be raised | | zmedico | from utime() calls. Instead of failing, use stat() to return | | | the mtime if possible. | | 9865 | Convert st_mtime to long for movefile() return type. | | zmedico | | svn path=/main/branches/prefix/; revision=9869 --- pym/portage/__init__.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index ff4281261..7554b8159 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -5262,11 +5262,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 -- 2.26.2