Don't check local file size for downloaded files.

This commit is contained in:
levlam 2022-10-09 21:20:57 +03:00
parent 683627a350
commit f86f8e5a85
3 changed files with 12 additions and 12 deletions

View File

@ -75,7 +75,7 @@ FileView DownloadManagerCallback::get_file_view(FileId file_id) {
}
FileView DownloadManagerCallback::get_sync_file_view(FileId file_id) {
td_->file_manager_->check_local_location(file_id);
td_->file_manager_->check_local_location(file_id, true);
return get_file_view(file_id);
}

View File

@ -1015,17 +1015,17 @@ static Status check_partial_local_location(const PartialLocalFileLocation &locat
return Status::OK();
}
void FileManager::check_local_location(FileId file_id) {
void FileManager::check_local_location(FileId file_id, bool skip_file_size_checks) {
auto node = get_sync_file_node(file_id);
if (node) {
check_local_location(node).ignore();
check_local_location(node, skip_file_size_checks).ignore();
}
}
Status FileManager::check_local_location(FileNodePtr node) {
Status FileManager::check_local_location(FileNodePtr node, bool skip_file_size_checks) {
Status status;
if (node->local_.type() == LocalFileLocation::Type::Full) {
status = check_local_location(node->local_.full(), node->size_, false);
status = check_local_location(node->local_.full(), node->size_, skip_file_size_checks);
} else if (node->local_.type() == LocalFileLocation::Type::Partial) {
status = check_partial_local_location(node->local_.partial());
}
@ -2070,7 +2070,7 @@ void FileManager::get_content(FileId file_id, Promise<BufferSlice> promise) {
if (!node) {
return promise.set_error(Status::Error("Unknown file_id"));
}
auto status = check_local_location(node);
auto status = check_local_location(node, true);
status.ignore();
auto file_view = FileView(node);
@ -2206,7 +2206,7 @@ void FileManager::download(FileId file_id, std::shared_ptr<DownloadCallback> cal
}
if (node->local_.type() == LocalFileLocation::Type::Full) {
auto status = check_local_location(node);
auto status = check_local_location(node, true);
if (status.is_error()) {
LOG(WARNING) << "Need to redownload file " << file_id << ": " << status;
} else {
@ -2217,7 +2217,7 @@ void FileManager::download(FileId file_id, std::shared_ptr<DownloadCallback> cal
return;
}
} else if (node->local_.type() == LocalFileLocation::Type::Partial) {
auto status = check_local_location(node);
auto status = check_local_location(node, true);
if (status.is_error()) {
LOG(WARNING) << "Need to download file " << file_id << " from beginning: " << status;
}
@ -2583,7 +2583,7 @@ void FileManager::resume_upload(FileId file_id, vector<int> bad_parts, std::shar
}
if (file_view.has_local_location() && new_priority != 0) {
auto status = check_local_location(node);
auto status = check_local_location(node, false);
if (status.is_error()) {
LOG(INFO) << "Full local location of file " << file_id << " for upload is invalid: " << status;
}
@ -2642,7 +2642,7 @@ bool FileManager::delete_partial_remote_location(FileId file_id) {
return false;
}
auto status = check_local_location(node);
auto status = check_local_location(node, false);
if (status.is_error()) {
LOG(INFO) << "Need full local location to upload file " << file_id << ": " << status;
return false;

View File

@ -452,7 +452,7 @@ 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 check_local_location(FileId file_id, bool skip_file_size_checks);
void download(FileId file_id, std::shared_ptr<DownloadCallback> callback, int32 new_priority, int64 offset,
int64 limit);
@ -618,7 +618,7 @@ class FileManager final : public FileLoadManager::Callback {
void load_from_pmc_result(FileId file_id, Result<FileData> &&result);
FileId register_pmc_file_data(FileData &&data);
Status check_local_location(FileNodePtr node);
Status check_local_location(FileNodePtr node, bool skip_file_size_checks);
static bool try_fix_partial_local_location(FileNodePtr node);
Status check_local_location(FullLocalFileLocation &location, int64 &size, bool skip_file_size_checks);
void try_flush_node_full(FileNodePtr node, bool new_remote, bool new_local, bool new_generate, FileDbId other_pmc_id);