Ensure the directory exists before creating the SQLite database #19980
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Resolves: #19948
Description
This linked issue indicates a problem when using unattended installs with a SQLite database for a newly cloned repository. The
/umbraco/Datadirectory doesn't exist which leads to an exception being thrown.I couldn't actually replicate this. In my tests I would always find a
MainDom_*.lockfile written into/umbraco/Data/Temp, so by the time the SQLite database was being created in the unattended install, the directory was already there.Nonetheless it's fairly easy to see what the fix would be if it wasn't - and if using storage in another location ensuring the directory exists would still be useful. So I've applied it here - a check to see if the directory where the SQLite database is going to be copied to exists, and if it doesn't, create it.
Testing
To test I found I needed to use a non-default location, so configure the something like the following for the database connection string:
And the following for unattended install:
Start up Umbraco. You should find that before these changes an exception would be thrown due to the directory not existing:
But with these changes in place it'll create it and start up normally.