Remove unpublished cipher block indexes during recovery

This commit is contained in:
evgeny committed 2026-10-18 10:47:24 +02:00
1 parent 057bdb3112
commit 7e08135bba
2 files changed
+6 -1

No files matched your search

+6
View File
@@ -574,6 +574,12 @@ static void ak_recover_preparations(struct UTUN_INSTANCE* inst) {
}
sqlite3_free_table(paths);
if (rows && !failed) {
const char* slash = strrchr(CC(inst)->db_path, '/');
unsigned prefix = slash ? (unsigned)(slash - CC(inst)->db_path) : 1;
char cleanup[768];
snprintf(cleanup, sizeof(cleanup), "DELETE FROM media_files WHERE chat_id='%s' AND location IN"
"(SELECT substr(a.cipher_path,%u) FROM attachment_keys a WHERE %s)", channel, prefix + 2, condition);
if (ak_exec(inst, cleanup)) continue;
snprintf(sql, sizeof(sql), "DELETE FROM attachment_keys AS a WHERE %s", condition);
if (!ak_exec(inst, sql)) DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "attachment keys: discarded unpublished preparations channel=%s count=%d", channel, rows);
}