Diff

Differences From Artifact [b782d4f8ad]:

To Artifact [6d048578b4]:


    57     57   
    58     58   		if {![info exists ::appfs::db]} {
    59     59   			file mkdir $::appfs::cachedir
    60     60   
    61     61   			sqlite3 ::appfs::db [file join $::appfs::cachedir cache.db]
    62     62   		}
    63     63   
    64         -		_db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest);}
           64  +		_db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest);}
    65     65   		_db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory);}
    66     66   	}
    67     67   
    68     68   	proc download {hostname hash {method sha1}} {
    69     69   		set url "http://$hostname/appfs/$method/$hash"
    70     70   		set file [_cachefile $url $hash]
    71     71   
................................................................................
   138    138   				continue
   139    139   			}
   140    140   
   141    141   			if {$pkgInfo(isLatest)} {
   142    142   				_db eval {UPDATE packages SET isLatest = 0 WHERE hostname = $hostname AND package = $pkgInfo($package) AND os = $pkgInfo($package) AND cpuArch = $pkgInfo(cpuArch);}
   143    143   			}
   144    144   
   145         -			_db eval {INSERT INTO packages (hostname, sha1, package, version, os, cpuArch, isLatest) VALUES ($hostname, $pkgInfo(hash), $pkgInfo(package), $pkgInfo(version), $pkgInfo(os), $pkgInfo(cpuArch), $pkgInfo(isLatest) );}
          145  +			_db eval {INSERT INTO packages (hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest) VALUES ($hostname, $pkgInfo(hash), $pkgInfo(package), $pkgInfo(version), $pkgInfo(os), $pkgInfo(cpuArch), $pkgInfo(isLatest), 0);}
   146    146   
   147    147   		}
   148    148   
   149    149   		return COMPLETE
   150    150   	}
   151    151   
   152    152   	proc getpkgmanifest {hostname package_sha1} {
          153  +		set haveManifests [_db eval {SELECT haveManifest FROM packages WHERE sha1 = $package_sha1 LIMIT 1;}]
          154  +		set haveManifest [lindex $haveManifests 0]
          155  +
          156  +		if {$haveManifest} {
          157  +			return COMPLETE
          158  +		}
          159  +
   153    160   		set file [download $hostname $package_sha1]
   154    161   		set fd [open $file]
   155    162   		set pkgdata [read $fd]
   156    163   		close $fd
   157    164   
   158    165   		foreach line [split $pkgdata "\n"] {
   159    166   			set line [string trim $line]
................................................................................
   185    192   				}
   186    193   				"symlink" {
   187    194   					set fileInfo(source) [lindex $work 0]
   188    195   				}
   189    196   			}
   190    197   
   191    198   			_db eval {INSERT INTO files (package_sha1, type, time, source, size, file_sha1, file_name, file_directory) VALUES ($package_sha1, $fileInfo(type), $fileInfo(time), $fileInfo(source), $fileInfo(size), $fileInfo(sha1), $fileInfo(name), $fileInfo(directory) );}
          199  +			_db eval {UPDATE packages SET haveManifest = 1 WHERE sha1 = $package_sha1;}
   192    200   		}
   193         -	}
   194    201   
          202  +		return COMPLETE
          203  +	}
   195    204   }