From a35c7c72f5a5da4a22dbd30f11bfcb2442696471 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 26 Sep 2022 11:49:48 +1000 Subject: [PATCH] Update database access exclusivity test for --resync (#2155) * Update database access exclusivity test for --resync --- src/main.d | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.d b/src/main.d index e1adafa5..d902ee02 100644 --- a/src/main.d +++ b/src/main.d @@ -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);