Check-in [d64cb6e110]
Overview
Comment:Updated with support for not redownloading manifest if it's already present
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d64cb6e110f07c32e991979a2d734d554b6dcbbf
User & Date: rkeene on 2014-09-08 02:50:11
Other Links: manifest | tags
Context
2014-09-08
02:55
Updated to not use KitDLL (not needed) check-in: c00111a8d5 user: rkeene tags: trunk
02:50
Updated with support for not redownloading manifest if it's already present check-in: d64cb6e110 user: rkeene tags: trunk
02:38
Separated manifest fetching from index fetching check-in: b5d1616f0f user: rkeene tags: trunk
Changes

Modified README.md from [15ef741d8b] to [1bb6f9042d].

    23     23       		type == file; extraData = size,sha1
    24     24   
    25     25       /opt/appfs/hostname/{sha1,package/os-cpuArch/version}/file
    26     26       	Fetches: http://hostname/appfs/sha1/<sha1>
    27     27   
    28     28   Database
    29     29   --------
    30         -    packages(hostname, sha1, package, version, os, cpuArch, isLatest)
           30  +    packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest)
    31     31       files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory)

Modified appfs.tcl from [b782d4f8ad] to [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   }