Make BinpkgFetcher synchronize the local timestamp of the downloaded file
authorZac Medico <zmedico@gentoo.org>
Fri, 12 Dec 2008 21:40:20 +0000 (21:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 12 Dec 2008 21:40:20 +0000 (21:40 -0000)
with the remote file, if the fetcher hasn't done it automatically.
(trunk r12201)

svn path=/main/branches/2.1.6/; revision=12234

pym/_emerge/__init__.py

index 3c2cf87c24cb8c9048dbe4e6b0d2f61d4ba563fd..a957b7136c2788d764f4e79b2830c4d96b10bb8f 100644 (file)
@@ -3443,6 +3443,30 @@ class BinpkgFetcher(SpawnProcess):
 
        def _set_returncode(self, wait_retval):
                SpawnProcess._set_returncode(self, wait_retval)
+               if self.returncode == os.EX_OK:
+                       # If possible, update the mtime to match the remote package if
+                       # the fetcher didn't already do it automatically.
+                       bintree = self.pkg.root_config.trees["bintree"]
+                       if bintree._remote_has_index:
+                               remote_mtime = bintree._remotepkgs[self.pkg.cpv].get("MTIME")
+                               if remote_mtime is not None:
+                                       try:
+                                               remote_mtime = float(remote_mtime)
+                                       except ValueError:
+                                               pass
+                                       else:
+                                               try:
+                                                       local_mtime = os.stat(self.pkg_path).st_mtime
+                                               except OSError:
+                                                       pass
+                                               else:
+                                                       if remote_mtime != local_mtime:
+                                                               try:
+                                                                       os.utime(self.pkg_path,
+                                                                               (remote_mtime, remote_mtime))
+                                                               except OSError:
+                                                                       pass
+
                if self.locked:
                        self.unlock()