1 |
commit: 13abe0398fbe724218c8c9ac2597ebe15d7db7e1 |
2 |
Author: W-Mark Kubacki <wmark <AT> hurrikane <DOT> de> |
3 |
AuthorDate: Wed Aug 1 19:12:24 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 2 00:54:44 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=13abe039 |
7 |
|
8 |
Fix index file's mtime, which can differ from TIMESTAMP. |
9 |
|
10 |
This enables Portage to reliably query for remote indices with |
11 |
HTTP-header If-Modified-Since. |
12 |
|
13 |
Without this patch mtime is greater than TIMESTAMP for large |
14 |
indices and slow storages - because writing a large file takes |
15 |
time. If the difference spans a second (TIMESTAMP 08:00:00, mtime |
16 |
08:00:01), then Portage will always fetch the remote index because |
17 |
it will appear being modified (mtime is used there) after the copy |
18 |
has been made (local copy's TIMESTAMP is used here). |
19 |
|
20 |
--- |
21 |
pym/portage/dbapi/bintree.py | 6 +++++- |
22 |
1 files changed, 5 insertions(+), 1 deletions(-) |
23 |
|
24 |
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py |
25 |
index 16ae8ec..0367503 100644 |
26 |
--- a/pym/portage/dbapi/bintree.py |
27 |
+++ b/pym/portage/dbapi/bintree.py |
28 |
@@ -1186,9 +1186,13 @@ class binarytree(object): |
29 |
pkgindex.packages.append(d) |
30 |
|
31 |
self._update_pkgindex_header(pkgindex.header) |
32 |
- f = atomic_ofstream(os.path.join(self.pkgdir, "Packages")) |
33 |
+ pkgindex_filename = os.path.join(self.pkgdir, "Packages") |
34 |
+ f = atomic_ofstream(pkgindex_filename) |
35 |
pkgindex.write(f) |
36 |
f.close() |
37 |
+ # some seconds might have elapsed since TIMESTAMP |
38 |
+ atime = mtime = long(pkgindex.header["TIMESTAMP"]) |
39 |
+ os.utime(pkgindex_filename, (atime, mtime)) |
40 |
finally: |
41 |
if pkgindex_lock: |
42 |
unlockfile(pkgindex_lock) |