Belt and braces
A week or two ago I was listening to some music, when it stopped. I investigated the FLAC file and discovered something nasty: it was corrupt. Both attempting to decode it and running an integrity check resulted in an error part way through.
I went to my backup drive, and discovered that the file was corrupted there as well. Presumably it had been corrupted somehow before I placed it on the server, maybe during the CD ripping process.
I suddenly wondered how many corrupt files I might have. It wasn’t too hard to write a Ruby script that slowly walked through all the FLAC files on the disk, running nice -n 19 flac --test --totally-silent filename.flac
for each of them and logging the results.
Once that had finished, I checked the logs and discovered I had exactly two corrupt files. Whew. I replaced them and relaxed.
I then updated the script to collect the music data checksums of every file in its reports too. A second script then allows me to compare that report with the output the previous time I ran the script. The output of that script is a report listing files that were removed, files that were added, and files that were moved.