Bug #139134 - Make the flat_hash and metadata modules write the _mtime_
authorZac Medico <zmedico@gentoo.org>
Mon, 17 Nov 2008 23:09:24 +0000 (23:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 17 Nov 2008 23:09:24 +0000 (23:09 -0000)
field inside the file instead of mangling the mtime of the cache entry
file. Also, fix FsBased._ensure_access() to properly skip the utime()
call when no mtime is passed in. Theses cache changes are compatible
with current stable portage (2.1.4.x), which uses the _mtime_ field
contained in the file when available.

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

pym/portage/cache/flat_hash.py
pym/portage/cache/fs_template.py

index 219a4a22dea3644f9ef41d64646e578d7fa869e3..b9781b0c7d7cd4e21c811a6fdd582c3b9af4ebf2 100644 (file)
@@ -18,6 +18,7 @@ class database(fs_template.FsBased):
                        self.label.lstrip(os.path.sep).rstrip(os.path.sep))
                write_keys = set(self._known_keys)
                write_keys.add("_eclasses_")
+               write_keys.add("_mtime_")
                self._write_keys = sorted(write_keys)
                if not self.readonly and not os.path.exists(self.location):
                        self._ensure_dirs()
@@ -83,7 +84,7 @@ class database(fs_template.FsBased):
                                myf.write("%s=%s\n" % (k, v))
                finally:
                        myf.close()
-               self._ensure_access(fp, mtime=values["_mtime_"])
+               self._ensure_access(fp)
 
                #update written.  now we move it.
 
index e619db0ac3c9d9bf44f87b8c6dd15ffffbcb3f6b..f3dc0ce44441876d5f57b887cd31b4a5b7c66013 100644 (file)
@@ -36,7 +36,7 @@ class FsBased(template.database):
                try:
                        os.chown(path, -1, self._gid)
                        os.chmod(path, self._perms)
-                       if mtime:
+                       if mtime != -1:
                                mtime=long(mtime)
                                os.utime(path, (mtime, mtime))
                except (OSError, IOError):