Remove unpublished cipher block indexes during recovery
This commit is contained in:
1 parent
057bdb3112
commit
7e08135bba
2 files changed
+6
-1
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
@@ -77,4 +77,3 @@ void dm_build_nonce(uint64_t conv_id, uint64_t author, uint64_t seq, uint8_t non
|
||||
SHA256_Final(hash, &ctx);
|
||||
memcpy(nonce, hash, DM_NONCE_SIZE);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user