From 119d40044ec464fb3740e14f8baac4e2607d03a9 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Tue, 29 Oct 2019 15:44:32 +0100 Subject: [PATCH] Adding the handle code for the SQLITE_BUSY return code in update_file. --- player/db/update.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/player/db/update.c b/player/db/update.c index 1cf6848d..29b60ad9 100644 --- a/player/db/update.c +++ b/player/db/update.c @@ -138,10 +138,14 @@ static int update_legacy_file(sqlite3 * db, const char * filename, size_t prefix } status_code = sqlite3_step(stmt); + if (status_code != SQLITE_DONE) { - // TODO handle SQLITE_BUSY (should rollback) serror(db, "Failed to execute insert statement"); + + if (status_code == SQLITE_BUSY && sqlite3_exec(db, "ROLLBACK;", 0, 0, 0) != SQLITE_OK) + { serror(db, "Failed to rollback transaction, database is corrupted"); } + goto error; } -- GitLab