bin/once: fix points problem

TODO: neale says points should be written to state/points.tmp then be moved into
state/points.new to avoid race condition (multiple processes touching the file
causing the file to change risking bad data in state/points.log). It might be
wise to do some validation in bin/points that tosses bad data.
This commit is contained in:
J. Patrick Avery, Jr 2015-06-06 22:17:55 -05:00
parent 75f4967cdb
commit 25fdd24173
1 changed files with 10 additions and 4 deletions

View File

@ -16,11 +16,17 @@ fi
# Collect new points
find state/points.new -type f | while read fn; do
# Skip partially-written files
[ $(wc -l < $fn) -eq 1 ] || continue
# Skip files opened by another process
lsof $fn | grep -q $fn && continue
cat $fn >> state/points.log
rm $fn
# Skip partially written files
[ $(wc -l < $fn) -gt 0 ] || continue
# filter the file for unique awards
sort -k 4 $fn | uniq -f 1 | sort -n >> state/points.log
# Now kill the file
rm -f $fn
done
# Generate new puzzles.html