Simplify local location check in FileManager::download.

This commit is contained in:
levlam 2022-10-10 12:11:40 +03:00
parent f1146d05bd
commit af3c33e481

View File

@ -2209,22 +2209,16 @@ void FileManager::download(FileId file_id, std::shared_ptr<DownloadCallback> cal
return;
}
auto status = check_local_location(node, true);
if (status.is_error()) {
LOG(WARNING) << "Need to redownload file " << file_id << ": " << status;
}
if (node->local_.type() == LocalFileLocation::Type::Full) {
auto status = check_local_location(node, true);
if (status.is_error()) {
LOG(WARNING) << "Need to redownload file " << file_id << ": " << status;
} else {
LOG(INFO) << "File " << file_id << " is already downloaded";
if (callback) {
callback->on_download_ok(file_id);
}
return;
}
} else if (node->local_.type() == LocalFileLocation::Type::Partial) {
auto status = check_local_location(node, true);
if (status.is_error()) {
LOG(WARNING) << "Need to download file " << file_id << " from beginning: " << status;
LOG(INFO) << "File " << file_id << " is already downloaded";
if (callback) {
callback->on_download_ok(file_id);
}
return;
}
FileView file_view(node);