2008-10-25 22:29:42 -06:00
|
|
|
#!/usr/bin/env rc
|
|
|
|
#. 9.rc # Not really needed when calling from werc, only would be needed if you use fproc_cache.rc standalone
|
2009-01-07 15:50:49 -07:00
|
|
|
# TODO: Allow to provide two arguments, second arg is a file name, use filename+size+mtime for hashing.
|
|
|
|
# Useful when dealing with many big files (eg., thumb gallery generation).
|
2008-10-25 22:29:42 -06:00
|
|
|
|
|
|
|
proc=$1
|
|
|
|
tmpfile=/tmp/fmttmp.$pid
|
|
|
|
score=`{{tee $tmpfile || exit 1} | sha1sum}
|
|
|
|
|
|
|
|
cachedir=/tmp/fproc_cache/$score
|
|
|
|
mkdir -p $cachedir >[2]/dev/null
|
|
|
|
|
2008-12-16 00:02:36 -07:00
|
|
|
if(test -s $cachedir/$proc)
|
2008-10-25 22:29:42 -06:00
|
|
|
cat $cachedir/$proc
|
2009-01-07 15:50:49 -07:00
|
|
|
if not
|
|
|
|
if($proc < $tmpfile | tee $cachedir/$pid)
|
|
|
|
mv $cachedir/$pid $cachedir/$proc
|
|
|
|
|
|
|
|
rm $tmpfile $cachedir/$pid >[2]/dev/null &
|