commit 2fbe1e02c7528eeaa6b05d2ca09829c32e132ba5
parent d7a4e6e2a9cc06ed09eb0616fa457aae55710eb9
Author: uriel@engel.se.cat-v.org <unknown>
Date: Wed, 7 Jan 2009 23:50:49 +0100
Minor optimizations and reliability improvments to fproc_cache.
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/bin/fproc_cache.rc b/bin/fproc_cache.rc
@@ -1,8 +1,9 @@
#!/usr/bin/env rc
#. 9.rc # Not really needed when calling from werc, only would be needed if you use fproc_cache.rc standalone
+# 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).
proc=$1
-
tmpfile=/tmp/fmttmp.$pid
score=`{{tee $tmpfile || exit 1} | sha1sum}
@@ -11,9 +12,8 @@ mkdir -p $cachedir >[2]/dev/null
if(test -s $cachedir/$proc)
cat $cachedir/$proc
-if not {
- # XXX For reliability mv should not be called unless both $proc and tee suceed
- $proc < $tmpfile | tee $cachedir/$pid
- mv $cachedir/$pid $cachedir/$proc
-}
-rm $tmpfile >[2]/dev/null
+if not
+ if($proc < $tmpfile | tee $cachedir/$pid)
+ mv $cachedir/$pid $cachedir/$proc
+
+rm $tmpfile $cachedir/$pid >[2]/dev/null &