From be6b4376e83987e6cc81720b301c962611273305 Mon Sep 17 00:00:00 2001 From: chme Date: Tue, 27 Dec 2016 21:31:01 +0100 Subject: [PATCH] [db] wrap db_purge_cruft in a transaction --- src/db.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/db.c b/src/db.c index 56b57023..eddd1b58 100644 --- a/src/db.c +++ b/src/db.c @@ -734,12 +734,15 @@ db_purge_cruft(time_t ref) "DELETE FROM files WHERE -1 <> %d AND db_timestamp < %" PRIi64 ";", }; + db_transaction_begin(); + for (i = 0; i < (sizeof(queries_tmpl) / sizeof(queries_tmpl[0])); i++) { query = sqlite3_mprintf(queries_tmpl[i], PL_SPECIAL, (int64_t)ref); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); + db_transaction_end(); return; } @@ -754,6 +757,7 @@ db_purge_cruft(time_t ref) if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); + db_transaction_end(); return; } @@ -763,6 +767,8 @@ db_purge_cruft(time_t ref) if (ret == 0) DPRINTF(E_DBG, L_DB, "Purged %d rows\n", sqlite3_changes(hdl)); + db_transaction_end(); + #undef Q_TMPL }