Diff

Differences From Artifact [fc1c954390]:

To Artifact [2fbc0cdff7]:


   123    123   
   124    124   		if {![info exists ::appfs::db]} {
   125    125   			file mkdir $::appfs::cachedir
   126    126   
   127    127   			sqlite3 ::appfs::db [file join $::appfs::cachedir cache.db]
   128    128   		}
   129    129   
          130  +		# Create tables
   130    131   		_db eval {CREATE TABLE IF NOT EXISTS sites(hostname PRIMARY KEY, lastUpdate, ttl);}
   131    132   		_db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest);}
   132    133   		_db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory);}
          134  +
          135  +		# Create indexes
          136  +		_db eval {CREATE INDEX IF NOT EXISTS sites_index ON sites (hostname);}
          137  +		_db eval {CREATE INDEX IF NOT EXISTS packages_index ON packages (hostname, package, version, os, cpuArch);}
          138  +		_db eval {CREATE INDEX IF NOT EXISTS files_index ON files (package_sha1, file_name, file_directory);}
   133    139   	}
   134    140   
   135    141   	proc download {hostname hash {method sha1}} {
   136    142   		set url "http://$hostname/appfs/$method/$hash"
   137    143   		set file [_cachefile $url $hash]
   138    144   
   139    145   		if {![file exists $file]} {