From 71981541068ab684bb7b75e192cd7171aa0ae657 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 22 Sep 2026 21:59:59 +0300 Subject: [PATCH] =?UTF-8?q?chatgui:=20=D0=BA=D0=BB=D0=B8=D0=BA=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BC=D0=B5=D0=B4=D0=B8=D0=B0=20=D1=81=20=D0=BE=D1=82?= =?UTF-8?q?=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B8?= =?UTF-8?q?=D0=BC=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=BC=20=E2=80=94=20?= =?UTF-8?q?=D1=81=D0=B1=D1=80=D0=BE=D1=81=20=D0=BF=D0=BE=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=B0?= =?UTF-8?q?=D1=87=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/chat_msg.c | 4 ++++ tools/chatgui/src/messagedelegate.cpp | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/chat/chat_msg.c b/src/chat/chat_msg.c index 6bb93a7c..e445757c 100644 --- a/src/chat/chat_msg.c +++ b/src/chat/chat_msg.c @@ -970,6 +970,10 @@ void chat_core_attachment_download(struct UTUN_INSTANCE* inst, const char* chann uint8_t author_sig[64]; memcpy(author_sig, sig_blob, 64); sqlite3_finalize(st); + /* сбрасываем пометку «файл есть»: файл мог быть вычищен кешем, а local_attrs ещё "fl". + по завершении md_download_done_cb снова запишет st=fl (успех) или st=er (ошибка). */ + chat_core_update_local_attrs(inst, channel_id, (uint64_t)db_ts, author_sig, "{}"); + DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "%s: manual download ch=%s id=%lld ct=%s file=%s", CC_ID, channel_id, (long long)msg_id, content_type, base_filename); md_start_download(inst, body, bi, channel_id, base_filename, (uint64_t)db_ts, author_sig, (uint64_t)author_node_id, msg_id, content_type); diff --git a/tools/chatgui/src/messagedelegate.cpp b/tools/chatgui/src/messagedelegate.cpp index 10e306a8..f7131cc2 100644 --- a/tools/chatgui/src/messagedelegate.cpp +++ b/tools/chatgui/src/messagedelegate.cpp @@ -92,7 +92,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, m_videoOpenCb(fp); return true; } - return false; + /* файл пропал (вычистка кеша/удаление) — перекачиваем ниже */ } if (dlState == 1) return false; /* скачивается */ @@ -119,7 +119,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, m_imageOpenCb(fp); return true; } - return false; + /* файл пропал (вычистка кеша/удаление) — перекачиваем ниже */ } if (dlState == 1) return false; /* скачивается */ @@ -142,11 +142,13 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, if (dlState == 2) { /* downloaded: open file */ QString fp = index.data(MsgVoiceFileRole).toString(); - if (!fp.isEmpty() && QFile::exists(fp)) + if (!fp.isEmpty() && QFile::exists(fp)) { QDesktopServices::openUrl(QUrl::fromLocalFile(fp)); - return true; + return true; + } + /* файл пропал (вычистка кеша/удаление) — перекачиваем ниже */ } - if (dlState != 0) return false; /* downloading — no action */ + if (dlState == 1) return false; /* downloading — no action */ if (chId.isEmpty() || msgId <= 0) return false; struct attachment_dl_req* req = (struct attachment_dl_req*) @@ -178,8 +180,9 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, (int)onPlayBtn, (int)onWaveform, qPrintable(filePath), QFile::exists(filePath), dlState, (long long)msgId); - /* not downloaded: start download (play will start on completion) */ - if (filePath.isEmpty() && dlState != 1) { + /* not downloaded (or file evicted): start download (play will start on completion) */ + bool fileMissing = filePath.isEmpty() || !QFile::exists(filePath); + if (fileMissing && dlState != 1) { if (chId.isEmpty() || msgId <= 0) return false; struct attachment_dl_req* req = (struct attachment_dl_req*) u_malloc(sizeof(struct attachment_dl_req)); @@ -193,7 +196,7 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, return true; } - if (filePath.isEmpty()) return false; + if (fileMissing) return false; GUI_DEBUG("editorEvent voice click: filePath=%s exists=%d wave=%d", qPrintable(filePath), QFile::exists(filePath), (int)onWaveform); if (filePath.isEmpty()) return false;