chatgui: клик по медиа с отсутствующим файлом — сброс пометки и перекачка
This commit is contained in:
1 parent
d237dfec7c
commit
7198154106
2 files changed
+15
-8
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user