1
2
3
4
5
6
7
8
9
10
11
|
#! /usr/bin/env tclsh
package require http 2.7
package require sqlite3
namespace eval ::appfs {
variable cachedir "/tmp/appfs-cache"
variable ttl 3600
variable nttl 60
proc _hash_sep {hash {seps 4}} {
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
|
#! /usr/bin/env tclsh
package require http 2.7
package require sqlite3
package require sha1
namespace eval ::appfs {
variable cachedir "/tmp/appfs-cache"
variable ttl 3600
variable nttl 60
proc _hash_sep {hash {seps 4}} {
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
} else {
set ncode "900"
}
close $fd
if {$keyIsHash} {
catch {
set hash [string tolower [exec openssl sha1 $tmpfile]]
regsub {.*= *} $hash {} hash
}
} else {
set hash $key
}
if {$ncode == "200" && $hash == $key} {
file rename -force -- $tmpfile $file
|
>
|
<
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
} else {
set ncode "900"
}
close $fd
if {$keyIsHash} {
set hash "__UNABLE_TO_COMPUTE_HASH__"
catch {
set hash [string tolower [sha1::sha1 -hex -file $tmpfile]]
}
} else {
set hash $key
}
if {$ncode == "200" && $hash == $key} {
file rename -force -- $tmpfile $file
|