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 091a4cd848
commit 8166469fee
1 changed files with 10 additions and 4 deletions

View File

@ -16,11 +16,17 @@ fi
# Collect new points # Collect new points
find state/points.new -type f | while read fn; do find state/points.new -type f | while read fn; do
# Skip partially-written files # Skip files opened by another process
[ $(wc -l < $fn) -eq 1 ] || continue lsof $fn | grep -q $fn && continue
cat $fn >> state/points.log # Skip partially written files
rm $fn [ $(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 done
# Generate new puzzles.html # Generate new puzzles.html