Skip to content

Commit

Permalink
Version 3.6.1: Fix video-from-webpage-preview download.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Mar 16, 2022
1 parent 81f9d04 commit eec2992
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions Telegram/SourceFiles/data/data_download_manager.cpp
Expand Up @@ -11,6 +11,7 @@ For license and copyright information please follow this link:
#include "data/data_photo.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
#include "data/data_web_page.h"
#include "data/data_changes.h"
#include "data/data_user.h"
#include "data/data_channel.h"
Expand Down Expand Up @@ -63,6 +64,28 @@ constexpr auto ByDocument = [](const auto &entry) {
return 0;
}

[[nodiscard]] PhotoData *ItemPhoto(not_null<HistoryItem*> item) {
if (const auto media = item->media()) {
if (const auto page = media->webpage()) {
return page->document ? nullptr : page->photo;
} else if (const auto photo = media->photo()) {
return photo;
}
}
return nullptr;
}

[[nodiscard]] DocumentData *ItemDocument(not_null<HistoryItem*> item) {
if (const auto media = item->media()) {
if (const auto page = media->webpage()) {
return page->document;
} else if (const auto document = media->document()) {
return document;
}
}
return nullptr;
}

struct DocumentDescriptor {
uint64 sessionUniqueId = 0;
DocumentId documentId = 0;
Expand Down Expand Up @@ -219,9 +242,8 @@ void DownloadManager::check(
std::vector<DownloadingId>::iterator i) {
auto &entry = *i;

const auto media = entry.object.item->media();
const auto photo = media ? media->photo() : nullptr;
const auto document = media ? media->document() : nullptr;
const auto photo = ItemPhoto(entry.object.item);
const auto document = ItemDocument(entry.object.item);
if (entry.object.photo != photo || entry.object.document != document) {
cancel(data, i);
return;
Expand Down

0 comments on commit eec2992

Please sign in to comment.