Diff

Differences From Artifact [1d195c7296]:

To Artifact [b7083177d4]:


     1      1   #! /usr/bin/env bash
            2  +
            3  +set -x
            4  +
            5  +appfsd_options=()
            6  +if [ "$1" == "--cachedir" ]; then
            7  +	appfsd_options=("${appfsd_options[@]}" '--cachedir' "$2")
            8  +
            9  +	shift; shift;
           10  +fi
           11  +
           12  +function call_appfsd() {
           13  +	appfsd "${appfsd_options[@]}" "$@"
           14  +}
     2     15   
     3     16   function invalidate() {
     4         -	appfsd -sqlite3 'UPDATE sites SET ttl = "0";'
           17  +	call_appfsd --sqlite3 'UPDATE sites SET ttl = "0";'
     5     18   }
     6     19   
     7     20   function remove_site() {
     8     21   	local site
     9     22   
    10     23   	site="$1"
    11     24   
    12         -	appfsd -sqlite3 'DELETE FROM sites WHERE hostname = '"'$site'"'; DELETE FROM packages WHERE hostname = '"'$site'"';' || return 1
           25  +	call_appfsd --sqlite3 'DELETE FROM sites WHERE hostname = '"'$site'"'; DELETE FROM packages WHERE hostname = '"'$site'"';' || return 1
    13     26   
    14     27   	clean
    15     28   }
    16     29   
    17     30   function clean() {
    18         -	appfsd -tcl "$(cat <<\_EOF_
           31  +	call_appfsd --tcl "$(cat <<\_EOF_
    19     32   		unset -nocomplain row
    20     33   		::appfs::db eval {SELECT sha1, hostname FROM packages;} row {
    21     34   			set hostname [::appfs::db onecolumn {SELECT hostname FROM sites WHERE hostname = $row(hostname) LIMIT 1;}]
    22     35   			if {$hostname == ""} {
    23     36   				continue
    24     37   			}
    25     38   
................................................................................
    51     64   
    52     65   	if [ -n "${package}" ]; then
    53     66   		echo "not implemented" >&2
    54     67   
    55     68   		return 1
    56     69   	fi
    57     70   
    58         -	appfsd -tcl 'file delete -force -- {*}[glob -directory $::appfs::cachedir {[0-9a-f][0-9a-f]}]' || return 1
    59         -	appfsd -sqlite3 'DELETE FROM sites; DELETE FROM packages; DELETE FROM files; VACUUM;' || return 1
           71  +	call_appfsd --tcl 'file delete -force -- {*}[glob -directory $::appfs::cachedir {[0-9a-f][0-9a-f]}]' || return 1
           72  +	call_appfsd --sqlite3 'DELETE FROM sites; DELETE FROM packages; DELETE FROM files; VACUUM;' || return 1
    60     73   }
    61     74   
    62     75   case "$1" in
    63     76   	invalidate)
    64     77   		invalidate || exit 1
    65     78   		;;
    66     79   	remove-site)