1 |
Author: zmedico |
2 |
Date: 2008-06-09 14:20:45 +0000 (Mon, 09 Jun 2008) |
3 |
New Revision: 10610 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/pym/portage.py |
7 |
Log: |
8 |
Add vardbapi.aux_get() support for an "_mtime_" value which corresponds to |
9 |
the installed package directory's mtime (numeric value from stat result). |
10 |
This value can be used to validate indexes or caches used in the optimization |
11 |
of vdb query operations for various types of package metadata such as |
12 |
dependencies and file contents. (trunk r10586) |
13 |
|
14 |
|
15 |
Modified: main/branches/2.1.2/pym/portage.py |
16 |
=================================================================== |
17 |
--- main/branches/2.1.2/pym/portage.py 2008-06-09 13:55:06 UTC (rev 10609) |
18 |
+++ main/branches/2.1.2/pym/portage.py 2008-06-09 14:20:45 UTC (rev 10610) |
19 |
@@ -7100,7 +7100,7 @@ |
20 |
mydir_mtime = long(mydir_stat.st_mtime) |
21 |
pkg_data = self._aux_cache["packages"].get(mycpv) |
22 |
pull_me = cache_these.union(wants) |
23 |
- mydata = {} |
24 |
+ mydata = {"_mtime_" : mydir_mtime} |
25 |
cache_valid = False |
26 |
cache_incomplete = False |
27 |
cache_mtime = None |
28 |
@@ -7124,7 +7124,8 @@ |
29 |
if pull_me: |
30 |
# pull any needed data and cache it |
31 |
aux_keys = list(pull_me) |
32 |
- for k, v in izip(aux_keys, self._aux_get(mycpv, aux_keys)): |
33 |
+ for k, v in izip(aux_keys, |
34 |
+ self._aux_get(mycpv, aux_keys, st=mydir_stat)): |
35 |
mydata[k] = v |
36 |
if not cache_valid or cache_these.difference(metadata): |
37 |
cache_data = {} |
38 |
@@ -7136,18 +7137,25 @@ |
39 |
self._aux_cache["modified"].add(mycpv) |
40 |
return [mydata[x] for x in wants] |
41 |
|
42 |
- def _aux_get(self, mycpv, wants): |
43 |
+ def _aux_get(self, mycpv, wants, st=None): |
44 |
mydir = os.path.join(self.root, VDB_PATH, mycpv) |
45 |
- try: |
46 |
- if not stat.S_ISDIR(os.stat(mydir).st_mode): |
47 |
- raise KeyError(mycpv) |
48 |
- except OSError, e: |
49 |
- if e.errno == errno.ENOENT: |
50 |
- raise KeyError(mycpv) |
51 |
- del e |
52 |
- raise |
53 |
+ if st is None: |
54 |
+ try: |
55 |
+ st = os.stat(mydir) |
56 |
+ except OSError, e: |
57 |
+ if e.errno == errno.ENOENT: |
58 |
+ raise KeyError(mycpv) |
59 |
+ elif e.errno == portage_exception.PermissionDenied.errno: |
60 |
+ raise portage_exception.PermissionDenied(mydir) |
61 |
+ else: |
62 |
+ raise |
63 |
+ if not stat.S_ISDIR(st.st_mode): |
64 |
+ raise KeyError(mycpv) |
65 |
results = [] |
66 |
for x in wants: |
67 |
+ if x == "_mtime_": |
68 |
+ results.append(st.st_mtime) |
69 |
+ continue |
70 |
try: |
71 |
myf = open(os.path.join(mydir, x), "r") |
72 |
try: |
73 |
|
74 |
-- |
75 |
gentoo-commits@l.g.o mailing list |