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 259339736c
commit 257933365e
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
# Skip partially written files
[ $(wc -l < $fn) -gt 0 ] || continue
cat $fn >> state/points.log # filter the file for unique awards
rm $fn 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