From 805e4d01e7971cea3fe9ef94b8f5e2c34d6c6206 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 21 Jan 2019 10:49:44 +0400 Subject: [PATCH] Allow re-downloading failed media. --- Telegram/SourceFiles/data/data_document.cpp | 3 ++- Telegram/SourceFiles/storage/file_download.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 39e53d4047..c0c442f2e2 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -379,7 +379,8 @@ void DocumentOpenClickHandler::Open( return; } - if (data->status != FileReady) return; + if (data->status != FileReady + && data->status != FileDownloadFailed) return; QString filename; if (!data->saveToCache() diff --git a/Telegram/SourceFiles/storage/file_download.cpp b/Telegram/SourceFiles/storage/file_download.cpp index fefdacb6c8..2583d085a7 100644 --- a/Telegram/SourceFiles/storage/file_download.cpp +++ b/Telegram/SourceFiles/storage/file_download.cpp @@ -945,7 +945,7 @@ int mtpFileLoader::finishSentRequestGetOffset(mtpRequestId requestId) { bool mtpFileLoader::feedPart(int offset, bytes::const_span buffer) { Expects(!_finished); - if (buffer.size()) { + if (!buffer.empty()) { if (_fileIsOpen) { auto fsize = _file.size(); if (offset < fsize) { @@ -978,7 +978,7 @@ bool mtpFileLoader::feedPart(int offset, bytes::const_span buffer) { } } } - if (!buffer.size() || (buffer.size() % 1024)) { // bad next offset + if (buffer.empty() || (buffer.size() % 1024)) { // bad next offset _lastComplete = true; } if (_sentRequests.empty()