Fix FileView::remote_size.

GitOrigin-RevId: 0d4ad73c4459c9d3dd31676f32dc39a445802b02
This commit is contained in:
levlam 2018-12-27 19:50:45 +03:00
parent 894038a881
commit b9bf652ad2
3 changed files with 11 additions and 7 deletions

View File

@ -3596,7 +3596,7 @@ class CliClient final : public Actor {
local_size = local_size * 2 - it->size;
}
send_request(
make_tl_object<td_api::setFileGenerationProgress>(it->id, (it->size + it->local_size) / 2, local_size));
make_tl_object<td_api::setFileGenerationProgress>(it->id, (it->size + 3 * it->local_size) / 4, local_size));
++it;
}
}

View File

@ -363,6 +363,11 @@ inline bool operator!=(const PartialRemoteFileLocation &lhs, const PartialRemote
return !(lhs == rhs);
}
inline StringBuilder &operator<<(StringBuilder &sb, const PartialRemoteFileLocation &location) {
return sb << '[' << (location.is_big_ ? "Big" : "Small") << " partial remote location with " << location.part_count_
<< " parts of size " << location.part_size_ << " with " << location.ready_part_count_ << " ready parts]";
}
struct PhotoRemoteFileLocation {
int64 id_;
int64 access_hash_;

View File

@ -439,7 +439,7 @@ int64 FileView::remote_size() const {
return res;
}
default:
return 0;
return node_->remote_ready_size_;
}
}
@ -2349,7 +2349,7 @@ void FileManager::on_partial_upload(QueryId query_id, const PartialRemoteFileLoc
auto file_id = query->file_id_;
auto file_node = get_file_node(file_id);
LOG(DEBUG) << "Receive on_partial_upload for file " << file_id;
LOG(DEBUG) << "Receive on_partial_upload for file " << file_id << " with " << partial_remote;
if (!file_node) {
return;
}
@ -2475,16 +2475,15 @@ void FileManager::on_partial_generate(QueryId query_id, const PartialLocalFileLo
auto file_id = query->file_id_;
auto file_node = get_file_node(file_id);
LOG(DEBUG) << "Receive on_partial_generate for file " << file_id << ": " << partial_local.path_ << " "
<< Bitmask(Bitmask::Decode{}, partial_local.ready_bitmask_);
auto bitmask = Bitmask(Bitmask::Decode{}, partial_local.ready_bitmask_);
LOG(DEBUG) << "Receive on_partial_generate for file " << file_id << ": " << partial_local.path_ << " " << bitmask;
if (!file_node) {
return;
}
if (file_node->generate_id_ != query_id) {
return;
}
auto ready_size = Bitmask(Bitmask::Decode{}, partial_local.ready_bitmask_)
.get_total_size(partial_local.part_size_, file_node->size_);
auto ready_size = bitmask.get_total_size(partial_local.part_size_, file_node->size_);
file_node->set_local_location(LocalFileLocation(partial_local), ready_size, -1, -1 /* TODO */);
// TODO check for size and local_size, abort generation if needed
if (expected_size > 0) {