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
24
25
26
27
28
29
30
31
    		type == file; extraData = size,sha1

    /opt/appfs/hostname/{sha1,package/os-cpuArch/version}/file
    	Fetches: http://hostname/appfs/sha1/<sha1>

Database
--------
    packages(hostname, sha1, package, version, os, cpuArch, isLatest)
    files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory)







|

23
24
25
26
27
28
29
30
31
    		type == file; extraData = size,sha1

    /opt/appfs/hostname/{sha1,package/os-cpuArch/version}/file
    	Fetches: http://hostname/appfs/sha1/<sha1>

Database
--------
    packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest)
    files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory)

Modified appfs.tcl from [b782d4f8ad] to [6d048578b4].

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

		if {![info exists ::appfs::db]} {
			file mkdir $::appfs::cachedir

			sqlite3 ::appfs::db [file join $::appfs::cachedir cache.db]
		}

		_db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest);}
		_db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory);}
	}

	proc download {hostname hash {method sha1}} {
		set url "http://$hostname/appfs/$method/$hash"
		set file [_cachefile $url $hash]








|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

		if {![info exists ::appfs::db]} {
			file mkdir $::appfs::cachedir

			sqlite3 ::appfs::db [file join $::appfs::cachedir cache.db]
		}

		_db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest);}
		_db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory);}
	}

	proc download {hostname hash {method sha1}} {
		set url "http://$hostname/appfs/$method/$hash"
		set file [_cachefile $url $hash]

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152







153
154
155
156
157
158
159
				continue
			}

			if {$pkgInfo(isLatest)} {
				_db eval {UPDATE packages SET isLatest = 0 WHERE hostname = $hostname AND package = $pkgInfo($package) AND os = $pkgInfo($package) AND cpuArch = $pkgInfo(cpuArch);}
			}

			_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) );}

		}

		return COMPLETE
	}

	proc getpkgmanifest {hostname package_sha1} {







		set file [download $hostname $package_sha1]
		set fd [open $file]
		set pkgdata [read $fd]
		close $fd

		foreach line [split $pkgdata "\n"] {
			set line [string trim $line]







|







>
>
>
>
>
>
>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
				continue
			}

			if {$pkgInfo(isLatest)} {
				_db eval {UPDATE packages SET isLatest = 0 WHERE hostname = $hostname AND package = $pkgInfo($package) AND os = $pkgInfo($package) AND cpuArch = $pkgInfo(cpuArch);}
			}

			_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);}

		}

		return COMPLETE
	}

	proc getpkgmanifest {hostname package_sha1} {
		set haveManifests [_db eval {SELECT haveManifest FROM packages WHERE sha1 = $package_sha1 LIMIT 1;}]
		set haveManifest [lindex $haveManifests 0]

		if {$haveManifest} {
			return COMPLETE
		}

		set file [download $hostname $package_sha1]
		set fd [open $file]
		set pkgdata [read $fd]
		close $fd

		foreach line [split $pkgdata "\n"] {
			set line [string trim $line]
185
186
187
188
189
190
191

192
193

194
195
				}
				"symlink" {
					set fileInfo(source) [lindex $work 0]
				}
			}

			_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) );}

		}
	}


}







>

|
>
|

192
193
194
195
196
197
198
199
200
201
202
203
204
				}
				"symlink" {
					set fileInfo(source) [lindex $work 0]
				}
			}

			_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) );}
			_db eval {UPDATE packages SET haveManifest = 1 WHERE sha1 = $package_sha1;}
		}

		return COMPLETE
	}
}