summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-10-29 14:26:10 +0100
committerMichael Schroeder <mls@suse.de>2012-10-29 14:26:10 +0100
commitd16e24a7df388dc2e8c2d373446d93f09ef3d517 (patch)
treeaaffb1319f0a1d707bf39e9a88f4d59dfd43a358 /examples
parent11477521f7d488de196df0fc0f855db9a906063f (diff)
downloadlibsolv-d16e24a7df388dc2e8c2d373446d93f09ef3d517.tar.gz
libsolv-d16e24a7df388dc2e8c2d373446d93f09ef3d517.tar.bz2
libsolv-d16e24a7df388dc2e8c2d373446d93f09ef3d517.zip
fix autorefresh flag in pysolv, support metadata_expire == -1 like in solv.c
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/p5solv2
-rwxr-xr-xexamples/pysolv5
-rwxr-xr-xexamples/rbsolv2
3 files changed, 4 insertions, 5 deletions
diff --git a/examples/p5solv b/examples/p5solv
index 94f5e7a..15487e1 100755
--- a/examples/p5solv
+++ b/examples/p5solv
@@ -52,7 +52,7 @@ sub load {
my $dorefresh = $self->{'autorefresh'};
if ($dorefresh) {
my @s = stat($self->cachepath());
- $dorefresh = 0 if @s && time() - $s[9] < $self->{'metadata_expire'};
+ $dorefresh = 0 if @s && ($self->{'metadata_expire'} == -1 || time() - $s[9] < $self->{'metadata_expire'});
}
$self->{'cookie'} = '';
if (!$dorefresh && $self->usecachedrepo()) {
diff --git a/examples/pysolv b/examples/pysolv
index 486ed98..f529d5d 100755
--- a/examples/pysolv
+++ b/examples/pysolv
@@ -75,12 +75,11 @@ class repo_generic(dict):
self.handle = pool.add_repo(self.name)
self.handle.appdata = self
self.handle.priority = 99 - self['priority']
- if self['autorefresh']:
- dorefresh = True
+ dorefresh = bool(int(self['autorefresh']))
if dorefresh:
try:
st = os.stat(self.cachepath())
- if time.time() - st[ST_MTIME] < self['metadata_expire']:
+ if self['metadata_expire'] == -1 or time.time() - st[ST_MTIME] < self['metadata_expire']:
dorefresh = False
except OSError, e:
pass
diff --git a/examples/rbsolv b/examples/rbsolv
index 333114b..c961b27 100755
--- a/examples/rbsolv
+++ b/examples/rbsolv
@@ -52,7 +52,7 @@ class Repo_generic
if dorefresh
begin
s = File.stat(cachepath)
- dorefresh = false if s && Time.now - s.mtime < @attribs['metadata_expire'].to_i
+ dorefresh = false if s && (@attribs['metadata_expire'].to_i == -1 || Time.now - s.mtime < @attribs['metadata_expire'].to_i)
rescue SystemCallError
end
end