Merge pull request #326 from chme/tx

[filescanner] Fix nested transaction
This commit is contained in:
ejurgensen 2016-12-27 22:15:10 +01:00 committed by GitHub
commit e4387fe33e
2 changed files with 8 additions and 3 deletions

View File

@ -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
}

View File

@ -1221,18 +1221,17 @@ bulk_scan(int flags)
}
else
{
db_transaction_begin();
/* Protect spotify from the imminent purge if rescanning */
db_transaction_begin();
db_file_ping_bymatch("spotify:", 0);
db_pl_ping_bymatch("spotify:", 0);
db_transaction_end();
DPRINTF(E_DBG, L_SCAN, "Purging old database content\n");
db_purge_cruft(start);
db_groups_cleanup();
db_queue_cleanup();
db_transaction_end();
cache_artwork_purge_cruft(start);
DPRINTF(E_LOG, L_SCAN, "Bulk library scan completed in %.f sec\n", difftime(end, start));