Overview
| Comment: | Added more functionality to "appfs-cache" control system |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | tcl-ops |
| Files: | files | file ages | folders |
| SHA1: |
82982300d8c0819e96e9caa95d951659 |
| User & Date: | rkeene on 2014-11-07 05:42:35 |
| Other Links: | branch diff | manifest | tags |
Context
|
2014-11-07
| ||
| 06:14 | Added comments check-in: 83dcb7cd52 user: rkeene tags: tcl-ops | |
| 05:42 | Added more functionality to "appfs-cache" control system check-in: 82982300d8 user: rkeene tags: tcl-ops | |
| 05:06 | Updated to include a Tcl interface via AppFSd check-in: 4b04c967f7 user: rkeene tags: tcl-ops | |
Changes
Modified appfs-cache from [8c72230216] to [1d195c7296].
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - + - + - + |
#! /usr/bin/env bash
function invalidate() {
appfsd -sqlite3 'UPDATE sites SET ttl = "0";'
}
function remove_site() {
local site
site="$1"
appfsd -sqlite3 'DELETE FROM sites WHERE hostname = '"'$site'"'; DELETE FROM packages WHERE hostname = '"'$site'"';' || return 1
clean
}
function clean() {
appfsd -tcl "$(cat <<\_EOF_
unset -nocomplain row
::appfs::db eval {SELECT sha1, hostname FROM packages;} row {
set hostname [::appfs::db onecolumn {SELECT hostname FROM sites WHERE hostname = $row(hostname) LIMIT 1;}]
if {$hostname == ""} {
continue
}
set valid_sha1($row(sha1)) 1
::appfs::db eval {SELECT file_sha1 FROM files WHERE file_sha1 IS NOT NULL AND file_sha1 != '' AND package_sha1 = $row(sha1);} subrow {
set valid_sha1($subrow(file_sha1)) 1
}
}
foreach file [glob -nocomplain -tails -directory $::appfs::cachedir {[0-9a-f][0-9a-f]/*/*/*/*}] {
set sha1 [string map [list "/" "" "\\" ""] $file]
set file [file join $::appfs::cachedir $file]
if {[info exists valid_sha1($sha1)]} {
continue
}
puts "Cleaning $file"
file delete -force -- $file
}
_EOF_
)"
}
function clear() {
local package
package="$1"
if [ -n "${package}" ]; then
echo "not implemented" >&2
return 1
fi
appfsd -tcl 'file delete -force -- {*}[glob -directory $::appfs::cachedir {[0-9a-f][0-9a-f]}]' || return 1
appfsd -sqlite3 'DELETE FROM sites; DELETE FROM packages; DELETE FROM files; VACUUM;' || return 1
}
case "$1" in
invalidate)
invalidate || exit 1
;;
|