-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
check if sqlite folder exists #2873
Conversation
1b358f9
to
986e962
Compare
This will not fix that specific issue. Since the data folder should actually exist already, since that is also where the JWT Keys are stored, and the config.json etc.. While this might help in detecting those issues, it doesn't filter out wrongly configured |
This change would only be for prevention of cases like #2835. It will not help with an existing misconfigured And in docker setups you won't notice the creation of this folders because you typically don't check |
The problem as I understood it was that if I specify a I'm not sure if we can catch all the ways a user might mistype/misconfigure the This change introduces a small inconvenience if you want your (new) sqlite database in a custom location, yes, but I think in most cases that is an acceptable tradeoff. Existing installations should not be affected by this, I think. |
The only thing we can do in cases like this is, check if it starts with The issue also is, that it could be that the environment variable isn't correctly visible, and i think that is what happens mostly, like when using quotes within a docker-compose file around only the value if i'm correct, but I'm not sure how those items actually work out. We can't detect an env variable spelling mistake for example, or a wrongly typed folder (especially if we create that folder manually hehe). So, you need to test several senarios with docker, docker-compose, podman maybe, baremetal binary etc... en all with different ways of defining the |
It's probably very uncommon for an SQLite database path to contain a colon, so that would be an easy heuristic for detecting It would also be very uncommon for any |
To keep a bit on topic of the PR, while the FP mentions it would solve an issue, which i think it doesn't directly, but there is an other PR for that. This does help people think about there directory structure, and if they configured it correctly. I do think that instead of creating the directory, and warning the user, and abort further loading is good. |
Aside from actually creating a file and getting a permission denied error, it is not easily possible to check if a directory is writeable (because on |
Okay, diesel will just return a |
7bed13d
to
8cc8376
Compare
I've added a second commit which improves the initial connection handling and just exit if there was an error. I am not sure if it makes sense to keep trying in case of sqlite but maybe this will break if a file system is not available yet? So maybe we should just log the error instead of exiting to not break anything? (Then the second commit does not really change anything except that we could be more helpful by pointing to permission issues...) |
8cc8376
to
4dd6c8f
Compare
d966963
to
66d25a0
Compare
Also I've removed the commit with my rather clunky check for a BadConnection again because my error message
was barely an improvement to the current error message
we get with the simpler let mut connection = diesel::sqlite::SqliteConnection::establish(&url)?; |
@stefan0xC I think you might have to click on request review again. Right now the status is |
instead of creating the parent folders to a sqlite database vaultwarden should just exit if it does not. this should fix issues like dani-garcia#2835 when a wrongly configured `DATABASE_URL` falls back to using sqlite
599f2ea
to
5a13efe
Compare
Instead of creating the parent folders to a sqlite database vaultwarden should just exit.
This should fix most issues like #2835 where a wrongly configured
DATABASE_URL
falls back to using sqlite.Fixes #2873