mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 16:25:03 -05:00
[db] wrap db_purge_cruft in a transaction
This commit is contained in:
parent
cf7787dbc2
commit
be6b4376e8
6
src/db.c
6
src/db.c
@ -734,12 +734,15 @@ db_purge_cruft(time_t ref)
|
|||||||
"DELETE FROM files WHERE -1 <> %d AND db_timestamp < %" PRIi64 ";",
|
"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++)
|
for (i = 0; i < (sizeof(queries_tmpl) / sizeof(queries_tmpl[0])); i++)
|
||||||
{
|
{
|
||||||
query = sqlite3_mprintf(queries_tmpl[i], PL_SPECIAL, (int64_t)ref);
|
query = sqlite3_mprintf(queries_tmpl[i], PL_SPECIAL, (int64_t)ref);
|
||||||
if (!query)
|
if (!query)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||||
|
db_transaction_end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,6 +757,7 @@ db_purge_cruft(time_t ref)
|
|||||||
if (!query)
|
if (!query)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||||
|
db_transaction_end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,6 +767,8 @@ db_purge_cruft(time_t ref)
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
DPRINTF(E_DBG, L_DB, "Purged %d rows\n", sqlite3_changes(hdl));
|
DPRINTF(E_DBG, L_DB, "Purged %d rows\n", sqlite3_changes(hdl));
|
||||||
|
|
||||||
|
db_transaction_end();
|
||||||
|
|
||||||
#undef Q_TMPL
|
#undef Q_TMPL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user