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
}
}
|