Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite for location and hash databases? #68

Open
noonat opened this issue Jan 8, 2016 · 2 comments
Open

SQLite for location and hash databases? #68

noonat opened this issue Jan 8, 2016 · 2 comments

Comments

@noonat
Copy link
Contributor

noonat commented Jan 8, 2016

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.

  1. Process 1 starts up, reads the contents of location.json.
  2. Process 2 starts up, reads the contents of location.json.
  3. Process 1 writes its changes to location.json.
  4. 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?

@jmathai
Copy link
Owner

jmathai commented Jan 8, 2016

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.

@jmathai
Copy link
Owner

jmathai commented Jan 8, 2016

Closing as a duplicate of gh-6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants