Call FileReferenceManager::get_file_search_text through DownloadManagerCallback.

This commit is contained in:
levlam 2022-07-23 17:01:27 +03:00
parent 061aac58db
commit ec19eaad65
4 changed files with 18 additions and 10 deletions

View File

@ -6,7 +6,6 @@
//
#include "td/telegram/DownloadManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileId.hpp"
#include "td/telegram/files/FileSourceId.hpp"
#include "td/telegram/Global.h"
@ -534,13 +533,13 @@ class DownloadManagerImpl final : public DownloadManager {
void prepare_hints() {
for (auto &it : files_) {
const auto &file_info = *it.second;
send_closure(G()->file_reference_manager(), &FileReferenceManager::get_file_search_text, file_info.file_source_id,
callback_->get_file_view(file_info.file_id).get_unique_file_id(),
[actor_id = actor_id(this), promise = load_search_text_multipromise_.get_promise(),
download_id = it.first](Result<string> r_search_text) mutable {
send_closure(actor_id, &DownloadManagerImpl::add_download_to_hints, download_id,
std::move(r_search_text), std::move(promise));
});
auto promise =
PromiseCreator::lambda([actor_id = actor_id(this), promise = load_search_text_multipromise_.get_promise(),
download_id = it.first](Result<string> r_search_text) mutable {
send_closure(actor_id, &DownloadManagerImpl::add_download_to_hints, download_id, std::move(r_search_text),
std::move(promise));
});
callback_->get_file_search_text(file_info.file_id, file_info.file_source_id, std::move(promise));
}
}

View File

@ -73,7 +73,8 @@ class DownloadManager : public Actor {
virtual void delete_file(FileId file_id) = 0;
virtual FileId dup_file_id(FileId file_id) = 0;
virtual FileView get_file_view(FileId file_id) = 0;
virtual void get_file_search_text(FileId file_id, FileSourceId file_source_id, Promise<string> &&promise) = 0;
virtual FileView get_sync_file_view(FileId file_id) = 0;
virtual td_api::object_ptr<td_api::fileDownload> get_file_download_object(FileId file_id,
FileSourceId file_source_id,

View File

@ -64,6 +64,12 @@ FileId DownloadManagerCallback::dup_file_id(FileId file_id) {
return td_->file_manager_->dup_file_id(file_id);
}
void DownloadManagerCallback::get_file_search_text(FileId file_id, FileSourceId file_source_id,
Promise<string> &&promise) {
send_closure(td_->file_reference_manager_actor_, &FileReferenceManager::get_file_search_text, file_source_id,
get_file_view(file_id).get_unique_file_id(), std::move(promise));
}
FileView DownloadManagerCallback::get_file_view(FileId file_id) {
return td_->file_manager_->get_file_view(file_id);
}

View File

@ -45,7 +45,7 @@ class DownloadManagerCallback final : public DownloadManager::Callback {
FileId dup_file_id(FileId file_id) final;
FileView get_file_view(FileId file_id) final;
void get_file_search_text(FileId file_id, FileSourceId file_source_id, Promise<string> &&promise) final;
FileView get_sync_file_view(FileId file_id) final;
@ -57,6 +57,8 @@ class DownloadManagerCallback final : public DownloadManager::Callback {
Td *td_;
ActorShared<> parent_;
FileView get_file_view(FileId file_id);
static std::shared_ptr<FileManager::DownloadCallback> make_download_file_callback(
Td *td, ActorShared<DownloadManager> download_manager);
};