In movefile(), always use stat_obj[stat.ST_MTIME] for the integral timestamp
authorZac Medico <zmedico@gentoo.org>
Wed, 9 Dec 2009 22:11:22 +0000 (22:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 9 Dec 2009 22:11:22 +0000 (22:11 -0000)
which is returned, since the stat_obj.st_mtime float attribute rounds *up* if
the nanosecond part of the timestamp is 999999881 ns or greater.

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

pym/portage/__init__.py

index 9cfe88866da3d462bcda585926403df313bb0fcf..2876c6b8c69d6b2950b9473d919466f6adb22d5b 100644 (file)
@@ -7623,9 +7623,12 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                        print("!!!",e)
                        return None
 
+       # Always use stat_obj[stat.ST_MTIME] for the integral timestamp which
+       # is returned,, since the stat_obj.st_mtime float attribute rounds *up*
+       # if the nanosecond part of the timestamp is 999999881 ns or greater.
        try:
                if hardlinked:
-                       newmtime = long(os.stat(dest).st_mtime)
+                       newmtime = os.stat(dest)[stat.ST_MTIME]
                else:
                        # Note: It is not possible to preserve nanosecond precision
                        # (supported in POSIX.1-2008 via utimensat) with the IEEE 754
@@ -7638,12 +7641,12 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
                                        # rename automatically preserves timestamps with complete
                                        # precision.
                                        os.utime(dest, (sstat.st_atime, sstat.st_mtime))
-                               newmtime = long(sstat.st_mtime)
+                               newmtime = sstat[stat.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)
+                       newmtime = os.stat(dest)[stat.ST_MTIME]
                except OSError as e:
                        writemsg(_("!!! Failed to stat in movefile()\n"), noiselevel=-1)
                        writemsg("!!! %s\n" % dest, noiselevel=-1)