PartsManager: some fixes
GitOrigin-RevId: fedd9458f18179cdabef579cdc251f8006a3f61e
This commit is contained in:
parent
cfe7b95be5
commit
655add2ec0
@ -66,10 +66,12 @@ void FileLoader::update_local_file_location(const LocalFileLocation &local) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileLoader::update_download_offset(int64 offset) {
|
void FileLoader::update_download_offset(int64 offset) {
|
||||||
parts_manager_.set_streaming_offset(offset);
|
if (parts_manager_.get_streaming_offset() != offset) {
|
||||||
//TODO: cancel only some queries
|
parts_manager_.set_streaming_offset(offset);
|
||||||
for (auto &it : part_map_) {
|
//TODO: cancel only some queries
|
||||||
it.second.second.reset(); // cancel_query(it.second.second);
|
for (auto &it : part_map_) {
|
||||||
|
it.second.second.reset(); // cancel_query(it.second.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
update_estimated_limit();
|
update_estimated_limit();
|
||||||
loop();
|
loop();
|
||||||
@ -279,6 +281,10 @@ void FileLoader::on_result(NetQueryPtr query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileLoader::on_part_query(Part part, NetQueryPtr query) {
|
void FileLoader::on_part_query(Part part, NetQueryPtr query) {
|
||||||
|
if (stop_flag_) {
|
||||||
|
// important for secret chats
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto status = try_on_part_query(part, std::move(query));
|
auto status = try_on_part_query(part, std::move(query));
|
||||||
if (status.is_error()) {
|
if (status.is_error()) {
|
||||||
on_error(std::move(status));
|
on_error(std::move(status));
|
||||||
|
@ -119,6 +119,9 @@ Result<FileLoader::PrefixInfo> FileUploader::on_update_local_location(const Loca
|
|||||||
file_type = location.partial().file_type_;
|
file_type = location.partial().file_type_;
|
||||||
} else {
|
} else {
|
||||||
path = location.full().path_;
|
path = location.full().path_;
|
||||||
|
if (path.empty()) {
|
||||||
|
return Status::Error("FullLocalFileLocation whith empty path");
|
||||||
|
}
|
||||||
local_is_ready = true;
|
local_is_ready = true;
|
||||||
file_type = location.full().file_type_;
|
file_type = location.full().file_type_;
|
||||||
}
|
}
|
||||||
@ -160,8 +163,9 @@ Result<FileLoader::PrefixInfo> FileUploader::on_update_local_location(const Loca
|
|||||||
fd_ = res_fd.move_as_ok();
|
fd_ = res_fd.move_as_ok();
|
||||||
fd_path_ = path;
|
fd_path_ = path;
|
||||||
is_temp_ = is_temp;
|
is_temp_ = is_temp;
|
||||||
|
} else if (!fd_path_.empty()) {
|
||||||
|
TRY_STATUS(acquire_fd());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local_is_ready) {
|
if (local_is_ready) {
|
||||||
CHECK(!fd_.empty());
|
CHECK(!fd_.empty());
|
||||||
TRY_RESULT(local_file_size, fd_.get_size());
|
TRY_RESULT(local_file_size, fd_.get_size());
|
||||||
|
@ -206,6 +206,9 @@ int32 PartsManager::get_ready_prefix_count() {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
int64 PartsManager::get_streaming_offset() const {
|
||||||
|
return streaming_offset_;
|
||||||
|
}
|
||||||
string PartsManager::get_bitmask() {
|
string PartsManager::get_bitmask() {
|
||||||
int32 prefix_count = -1;
|
int32 prefix_count = -1;
|
||||||
if (need_check_) {
|
if (need_check_) {
|
||||||
@ -452,7 +455,11 @@ void PartsManager::init_common(const std::vector<int> &ready_parts) {
|
|||||||
part_status_ = vector<PartStatus>(part_count_);
|
part_status_ = vector<PartStatus>(part_count_);
|
||||||
|
|
||||||
for (auto i : ready_parts) {
|
for (auto i : ready_parts) {
|
||||||
LOG_CHECK(0 <= i && i < part_count_) << tag("i", i) << tag("part_count", part_count_);
|
LOG_CHECK(0 <= i && i < part_count_) << tag("i", i) << tag("part_count", part_count_) << tag("size", size_)
|
||||||
|
<< tag("part_size", part_size_) << tag("known_prefix_flag", known_prefix_flag_)
|
||||||
|
<< tag("real part_count",
|
||||||
|
std::accumulate(ready_parts.begin(), ready_parts.end(), 0,
|
||||||
|
[](auto a, auto b) { return max(a, b + 1); }));
|
||||||
part_status_[i] = PartStatus::Ready;
|
part_status_[i] = PartStatus::Ready;
|
||||||
bitmask_.set(i);
|
bitmask_.set(i);
|
||||||
auto part = get_part(i);
|
auto part = get_part(i);
|
||||||
|
@ -50,6 +50,7 @@ class PartsManager {
|
|||||||
int32 get_part_count() const;
|
int32 get_part_count() const;
|
||||||
int32 get_unchecked_ready_prefix_count();
|
int32 get_unchecked_ready_prefix_count();
|
||||||
int32 get_ready_prefix_count();
|
int32 get_ready_prefix_count();
|
||||||
|
int64 get_streaming_offset() const;
|
||||||
string get_bitmask();
|
string get_bitmask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user