elodie
elodie copied to clipboard
SQLite for location and hash databases?
It seems like two instances of elodie.py importing simultaneous could conflict with each other's use of the location.json and hash.json files.
- Process 1 starts up, reads the contents of location.json.
- Process 2 starts up, reads the contents of location.json.
- Process 1 writes its changes to location.json.
- Process 2 writes its changes to location.json, but its copy does not contain process 1's changes.
This could be mitigated by reading the contents of the file before we write it, but that still allows for a race condition (just a less likely one). You could use fnctl to lock the file before writing it, which would work... and is, in fact what SQLite does.
Which leads me to think it might be simpler to use SQLite instead of implementing all this logic internally in Elodie. SQLite is supported by the Python stdlib, so there aren't any dependency issues.
Would you be open to a pull request that made this change?
The flat files are problematic for numerous reasons. SQLite is probably a better option for both location.json
and hash.json
. This is closely related to gh-6 though. There's a GUI app that the python scripts are bundled with so using OS standards for storing application data was possibly a desirable trait.
That being said, I would love a PR but I'd like to make sure it addresses gh-6 as well.
Closing as a duplicate of gh-6.