fix autorefresh flag in pysolv, support metadata_expire == -1 like in solv.c
authorMichael Schroeder <mls@suse.de>
Mon, 29 Oct 2012 13:26:10 +0000 (14:26 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 29 Oct 2012 13:26:10 +0000 (14:26 +0100)
examples/p5solv
examples/pysolv
examples/rbsolv

index 94f5e7a..15487e1 100755 (executable)
@@ -52,7 +52,7 @@ sub load {
   my $dorefresh = $self->{'autorefresh'};
   if ($dorefresh) {
     my @s = stat($self->cachepath());
   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()) {
   }
   $self->{'cookie'} = '';
   if (!$dorefresh && $self->usecachedrepo()) {
index 486ed98..f529d5d 100755 (executable)
@@ -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']
         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 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
                     dorefresh = False
             except OSError, e:
                 pass
index 333114b..c961b27 100755 (executable)
@@ -52,7 +52,7 @@ class Repo_generic
     if dorefresh
       begin
        s = File.stat(cachepath)
     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
       rescue SystemCallError
       end
     end