From 2576b69a8883553b52ef2d4bccf2c3277e14c5c0 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 2 Jun 2018 06:19:29 +1000 Subject: [PATCH] Resolve 'database is locked' message and crash * Resolve 'database is locked' when another onedrive process is running and has exclusive access to the database --- src/sqlite.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sqlite.d b/src/sqlite.d index 219a973e..561bbb2c 100644 --- a/src/sqlite.d +++ b/src/sqlite.d @@ -1,5 +1,5 @@ module sqlite; - +import std.stdio; import etc.c.sqlite3; import std.string: fromStringz, toStringz; @@ -133,6 +133,11 @@ struct Statement { // https://www.sqlite.org/c3ref/step.html int rc = sqlite3_step(pStmt); + if (rc == SQLITE_BUSY) { + // Database is locked by another onedrive process + writeln("The database is currently locked by another process - cannot sync"); + return; + } if (rc == SQLITE_DONE) { row.length = 0; } else if (rc == SQLITE_ROW) {