Something I forgot to mention earlier: If the files are not too big,
consider generating the SHA-512 on the fly instead of storing it.
Space-wise, it is the best possible optimization, obviously. And it
frees you from having to ensure consistency between the file and the hash.