From d16e24a7df388dc2e8c2d373446d93f09ef3d517 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 29 Oct 2012 14:26:10 +0100 Subject: fix autorefresh flag in pysolv, support metadata_expire == -1 like in solv.c --- examples/p5solv | 2 +- examples/pysolv | 5 ++--- examples/rbsolv | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'examples') 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 -- cgit v1.2.3