thirdculture-werc/bin/fproc_cache.rc
Uriel 4d36a9a57d Make fproc more reliable (fool-proof).
For some reason I have found empty files showing up in cache dirs, this should at least clean them up.
2008-12-16 07:02:36 +00:00

18 lines
444 B
Bash
Executable file

#!/usr/bin/env rc
#. 9.rc # Not really needed when calling from werc, only would be needed if you use fproc_cache.rc standalone
proc=$1
tmpfile=/tmp/fmttmp.$pid
score=`{{tee $tmpfile || exit 1} | sha1sum}
cachedir=/tmp/fproc_cache/$score
mkdir -p $cachedir >[2]/dev/null
if(test -s $cachedir/$proc)
cat $cachedir/$proc
if not {
$proc < $tmpfile | tee $cachedir/$pid
mv $cachedir/$pid $cachedir/$proc
}
rm $tmpfile >[2]/dev/null