From d4efdba44e5afaf0a410b8376235cff97d9f979f Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 22 Oct 2026 14:56:07 +0200 Subject: [PATCH] Retain failed download destinations for later cleanup --- src/chat/chat_msg.c | 2 +- src/media_delivery/media_download.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chat/chat_msg.c b/src/chat/chat_msg.c index 83bb2af3..934c1fa0 100644 --- a/src/chat/chat_msg.c +++ b/src/chat/chat_msg.c @@ -1596,7 +1596,7 @@ static void cache_file_collect_cb(const struct media_msg_file* f, void* arg) { /* Фактическая сумма размеров файлов, соответствующих сообщениям. */ static uint64_t chat_media_cache_scan_sum(struct chat_core_ctx* cc) { char media_base[MEDIA_BASE_MAX]; - if (media_index_get_base(cc->db, media_base)) return; + if (media_index_get_base(cc->db, media_base)) return cc->media_cache_bytes; struct cache_file_list files = {0}; chat_media_foreach_media_message(cc, media_base, cache_file_collect_cb, &files); uint64_t sum = 0; diff --git a/src/media_delivery/media_download.c b/src/media_delivery/media_download.c index 857a3d72..ef677091 100644 --- a/src/media_delivery/media_download.c +++ b/src/media_delivery/media_download.c @@ -880,6 +880,8 @@ int media_download_start(struct UTUN_INSTANCE* inst, uint64_t group_id, DEBUG_WARN(DEBUG_CATEGORY_GENERAL, "%s: DUPLICATE download media=%02x%02x... ignored", MDL_ID, result->media_id[0], result->media_id[1]); return 0; } + char channel[32]; snprintf(channel, sizeof(channel), "%llu", (unsigned long long)group_id); + if (media_index_track_preparation(inst->topo_sqlite_db, channel, dest_path, media_base)) return -1; struct media_download* dl = u_calloc(1, sizeof(*dl)); if (!dl) { DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, "%s: u_calloc for download failed", MDL_ID); return -1; }