]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
examples: initialize extcookie
authorMichael Schroeder <mls@suse.de>
Fri, 28 Aug 2015 12:20:56 +0000 (14:20 +0200)
committerMichael Schroeder <mls@suse.de>
Fri, 28 Aug 2015 12:20:56 +0000 (14:20 +0200)
examples/p5solv
examples/pysolv
examples/rbsolv
examples/tclsolv

index 864cf3eb6a9486bea6b123a5af4205d1d0124d4a..68be64f8da3666e36c815195a45b45d31f01e1ae 100755 (executable)
@@ -65,6 +65,7 @@ sub load {
     $dorefresh = 0 if @s && ($self->{metadata_expire} == -1 || time() - $s[9] < $self->{metadata_expire});
   }
   $self->{cookie} = '';
+  $self->{extcookie} = '';
   if (!$dorefresh && $self->usecachedrepo()) {
     print "repo: '$self->{alias}' cached\n";
     return 1;
index 2a6b28a9fabd0b4d5dda951973a6153968f95032..525623bc35d4cb061193774df008d59d7add7a03 100755 (executable)
@@ -91,6 +91,7 @@ class repo_generic(dict):
             except OSError:
                 pass
         self['cookie'] = ''
+        self['extcookie'] = ''
         if not dorefresh and self.usecachedrepo(None):
             print("repo: '%s': cached" % self.name)
             return True
@@ -247,7 +248,7 @@ class repo_generic(dict):
                 self.handle.write_first_repodata(f)
             f.flush()
             if self.type != 'system' and not ext:
-                if 'extcookie' not in self:
+                if not self['extcookie']:
                     self['extcookie'] = self.calc_cookie_ext(f, self['cookie'])
                 f.write(self['extcookie'])
             if not ext:
index a2d48e6011ede7177d0c380cdc4ed08e1cffe0d6..144a0dd848e3fecea4263891267e0327bfbf3549 100755 (executable)
@@ -66,6 +66,7 @@ class Repo_generic
       end
     end
     @cookie = nil
+    @extcookie = nil
     if !dorefresh && usecachedrepo(nil)
       puts "repo: '#{@name}' cached"
       return true
index 1ea6ef966bd04710d085abc762b37865bf7be8b0..27e1466ea33b3cf56267174c173bff3a21283713 100755 (executable)
@@ -47,11 +47,7 @@ proc repo_calc_cookie_ext {selfName f cookie} {
   $chksum add "1.1"
   $chksum add $cookie
   $chksum add_fstat [$f fileno]
-  set extcookie [$chksum raw]
-  if {[string index $extcookie 0] eq "\000"} {
-    set extcookie [string replace $extcookie 0 0 "\001"]
-  }
-  return $extcookie
+  return [$chksum raw]
 }
 
 proc repo_cachepath {selfName {ext "-"}} {
@@ -79,6 +75,7 @@ proc repo_generic_load {selfName pool} {
     }
   }
   set self(cookie) {}
+  set self(extcookie) {}
   if { !$dorefresh && [repo_usecachedrepo self] } {
     puts "repo $self(name): cached"
     return 1 
@@ -157,7 +154,7 @@ proc repo_writecachedrepo {selfName {ext "-"} {repodata "NULL"}} {
   }
   $f flush
   if {$self(type) ne "system" && $ext eq "-"} {
-    if {![info exists self(extcookie)]} {
+    if {$self(extcookie) eq {}} {
       set self(extcookie) [repo_calc_cookie_ext self $f $self(cookie)]
     }
     $f write $self(extcookie)