blob: 9394724a3f4b8e2b0a892f456f1b550fcc16e434 (
plain) (
blame)
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
|
#!/bin/rc
fn fltr_cache {
a=()
tmpf=()
proc=$1
shift
if(~ $#* 0) {
tmpf=/tmp/fmttmp.$pid
f=$tmpf
score=`{{tee $tmpf || exit 1} | sha1sum}
}
if not {
f=$1
if(~ $f */) {
score=`{du -an $f | sha1sum || exit 1} # XXX using -n(bytes) instead of -t(lastmod) because sitemap proc touches files in tree.
a=$f
f=/dev/null
}
if not {
score=`{sha1sum $f || exit 1}
score=$score(1)
}
}
cachedir=/tmp/fltr_cache/$score
mkdir -p $cachedir >[2]/dev/null
if(test -s $cachedir/$proc)
cat $cachedir/$proc
if not
if($proc $a < $f | tee $cachedir/$pid)
mv $cachedir/$pid $cachedir/$proc
rm $tmpf $cachedir/$pid >[2]/dev/null &
}
|