Skip to content

Commit

Permalink
FileUpload: restart automatically if part_size is too small
Browse files Browse the repository at this point in the history
GitOrigin-RevId: bbfe3f0fca2f888f6bd4d2909935903d7c4e3b33
  • Loading branch information
arseny30 authored and levlam committed Jan 29, 2018
1 parent 674a993 commit c329826
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions td/telegram/files/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2190,6 +2190,11 @@ void FileManager::on_error_impl(FileNode *node, FileManager::Query::Type type, b
}
}

if (status.message() == "FILE_UPLOAD_RESTART") {
run_upload(node, {});
return;
}

if (!was_active) {
return;
}
Expand Down
3 changes: 3 additions & 0 deletions td/telegram/files/FileUploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ Result<FileLoader::PrefixInfo> FileUploader::on_update_local_location(const Loca
}

local_size_ = local_size;
if (expected_size_ < local_size_) {
expected_size_ = local_size_;
}
local_is_ready_ = local_is_ready;
file_type_ = file_type;

Expand Down
3 changes: 1 addition & 2 deletions td/telegram/files/PartsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ Status PartsManager::init(int64 size, bool is_size_final, size_t part_size, cons
if (part_size != 0) {
part_size_ = part_size;
if (use_part_count_limit_ && (size_ + part_size_ - 1) / part_size_ > MAX_PART_COUNT) {
return Status::Error(PSLICE() << "Should restart load with bigger part_size " << tag("part_size_", part_size_)
<< tag("size", size_));
return Status::Error("FILE_UPLOAD_RESTART");
}
} else {
// TODO choose part_size_ depending on size
Expand Down

0 comments on commit c329826

Please sign in to comment.