Repository navigation
Fix installing on LiteDB - #997
Merged
Merged
Conversation
CreateTables opened a database context before checking the provider. For LiteDB that is a second LiteDatabase on the file the one registered in DI already holds, so the installation failed with "being used by another process". The context is only needed for MongoDB and is now created there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type: bugfix
Issue
A new installation on LiteDB fails with "Setup failed: The process cannot access the file '...\App_Data\database.db' because it is being used by another process."
InstallationService.CreateTablesasksIDatabaseFactoryContextfor a database context before it checks the provider. For LiteDB that opens a secondLiteDatabaseonApp_Data/database.db, which theLiteDatabaseregistered in DI already holds open, and LiteDB refuses the second handle. The context is only used for MongoDB (LiteDB has no tables or indexes to create there), so the failing open is also unnecessary.To reproduce on
develop: setDatabase:UseLiteDbtotrueinApp_Data/appsettings.json, start the app, choose LiteDB in the installer and install.Solution
Create the database context only inside the MongoDB branch of
CreateTables. The MongoDB path is unchanged.Breaking changes
None.
Testing
"UseLiteDb": trueinsrc/Web/Grand.Web/App_Data/appsettings.json, deleteApp_Data/Settings.cfgandApp_Data/database.dbif present./install, choose LiteDB, tick sample data and install. Before the fix this fails with the message above; with the fix it completes./Admin/Product/Listwith the sample products).