Improve kara checksum comparison
In order to decide if a database needs to be regenerated, a checksum of all .kara and series files is made on startup. If the checksum is not the one in database, database is regenerated.
It's simple and efficient, but when someone edits/adds/removes a karaoke, this checksum changes, and to recalculate it, we go through the whole comparison again, resulting in a lot of files being read at once. If somehow a .kara disappears, it'll cause KM to crash because we're not catching these kind oferrors (they're not supposed to happen anyway)
What we could do is the following
- Store the contents of kara and series files in a JSON array object in memory. A checksum of
JSON.stringify()
is made of that object. The checksum is stored in database - Whenever we add/edit/modify a karaoke instead of recomparing everything, we filter/edit/add and sort the array in memory and recalculate the checksum so it doesn't check files anymore.
- Once recalculated, the checksum is written to database, and we don't try to re-read 10000+ files at once.