Update database access exclusivity test for --resync (#2155)

* Update database access exclusivity test for --resync
This commit is contained in:
abraunegg 2022-09-26 11:49:48 +10:00 committed by GitHub
parent e2ed2d2b58
commit a35c7c72f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -789,8 +789,19 @@ int main(string[] args)
log.vdebug("Testing if we have exclusive access to local database file");
// Are we the only running instance? Test that we can open the database file path
itemDb = new ItemDatabase(cfg.databaseFilePath);
destroy(itemDb);
// did we successfully initialise the database class?
if (!itemDb.isDatabaseInitialised()) {
// no .. destroy class
itemDb = null;
// exit application
return EXIT_FAILURE;
}
// If we have exclusive access we will not have exited
// destroy access test
destroy(itemDb);
// delete application sync state
log.log("Deleting the saved application sync status ...");
if (!cfg.getValueBool("dry_run")) {
safeRemove(cfg.databaseFilePath);