ssb: Clean up outdated dynamic blob_wants_cache entries.

This commit is contained in:
Cory McWilliams 2025-05-21 17:44:00 -04:00
parent 0d7dfd8c9e
commit 8a0e190a86
2 changed files with 14 additions and 1 deletions

View File

@ -224,7 +224,9 @@ class TfElement extends LitElement {
for (let id of ids_out_of_date) {
if (!cache.about[id]?.seq) {
cache.about[id] = Object.assign(cache.about[id] ?? {}, {seq: users[id]?.seq ?? 0});
cache.about[id] = Object.assign(cache.about[id] ?? {}, {
seq: users[id]?.seq ?? 0,
});
}
}

View File

@ -1505,6 +1505,17 @@ static void _tf_ssb_rpc_delete_blobs_work(tf_ssb_t* ssb, void* user_data)
int64_t timestamp = now - age * 1000ULL;
const int k_limit = 128;
int deleted = 0;
if (sqlite3_prepare(db, "DELETE FROM blob_wants_cache WHERE source IS NULL and timestamp < ?1", -1, &statement, NULL) == SQLITE_OK)
{
if (sqlite3_bind_int64(statement, 1, timestamp) == SQLITE_OK)
{
if (sqlite3_step(statement) != SQLITE_DONE)
{
tf_printf("Deleting stale blob wants cache entries: %s.\n", sqlite3_errmsg(db));
}
}
sqlite3_finalize(statement);
}
if (sqlite3_prepare(db,
"DELETE FROM blobs WHERE blobs.id IN ("
" SELECT blobs.id FROM blobs "