Check local location of files when adding them to download manager.

This commit is contained in:
levlam 2022-07-20 16:46:55 +03:00
parent 51513f1780
commit 4ac8be8122
3 changed files with 11 additions and 1 deletions

View File

@ -69,7 +69,8 @@ FileView DownloadManagerCallback::get_file_view(FileId file_id) {
}
FileView DownloadManagerCallback::get_sync_file_view(FileId file_id) {
return td_->file_manager_->get_sync_file_view(file_id);
td_->file_manager_->check_local_location(file_id);
return get_file_view(file_id);
}
td_api::object_ptr<td_api::fileDownload> DownloadManagerCallback::get_file_download_object(

View File

@ -1016,6 +1016,13 @@ static Status check_partial_local_location(const PartialLocalFileLocation &locat
return Status::OK();
}
void FileManager::check_local_location(FileId file_id) {
auto node = get_sync_file_node(file_id);
if (node) {
check_local_location(node).ignore();
}
}
Status FileManager::check_local_location(FileNodePtr node) {
Status status;
if (node->local_.type() == LocalFileLocation::Type::Full) {

View File

@ -447,6 +447,8 @@ class FileManager final : public FileLoadManager::Callback {
bool set_encryption_key(FileId file_id, FileEncryptionKey key);
bool set_content(FileId file_id, BufferSlice bytes);
void check_local_location(FileId file_id);
void download(FileId file_id, std::shared_ptr<DownloadCallback> callback, int32 new_priority, int64 offset,
int64 limit);
void upload(FileId file_id, std::shared_ptr<UploadCallback> callback, int32 new_priority, uint64 upload_order);