Remove update_local_file_location from FileLoaderActor.
This commit is contained in:
parent
34e81dc272
commit
ee4794b343
@ -137,9 +137,6 @@ class FileDownloader final : public FileLoaderActor {
|
||||
|
||||
void update_resources(const ResourceState &other) final;
|
||||
|
||||
void update_local_file_location(const LocalFileLocation &local) final {
|
||||
}
|
||||
|
||||
void update_downloaded_part(int64 offset, int64 limit, int64 max_resource_limit) final;
|
||||
|
||||
void start_up() final;
|
||||
|
@ -23,8 +23,6 @@ class FileLoaderActor : public NetQueryCallback {
|
||||
virtual void update_resources(const ResourceState &other) = 0;
|
||||
|
||||
// TODO: existence of these two functions is a dirty hack. Refactoring is highly appreciated
|
||||
virtual void update_local_file_location(const LocalFileLocation &local) {
|
||||
}
|
||||
virtual void update_downloaded_part(int64 offset, int64 limit, int64 max_resource_limit) {
|
||||
}
|
||||
};
|
||||
|
@ -36,10 +36,10 @@ void FileUploadManager::upload(QueryId query_id, const LocalFileLocation &local_
|
||||
CHECK(node);
|
||||
node->query_id_ = query_id;
|
||||
auto callback = make_unique<FileUploaderCallback>(actor_shared(this, node_id));
|
||||
node->loader_ = create_actor<FileUploader>("Uploader", local_location, remote_location, expected_size, encryption_key,
|
||||
std::move(bad_parts), std::move(callback));
|
||||
node->uploader_ = create_actor<FileUploader>("Uploader", local_location, remote_location, expected_size,
|
||||
encryption_key, std::move(bad_parts), std::move(callback));
|
||||
send_closure(upload_resource_manager_, &ResourceManager::register_worker,
|
||||
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
|
||||
ActorShared<FileLoaderActor>(node->uploader_.get(), static_cast<uint64>(-1)), priority);
|
||||
bool is_inserted = query_id_to_node_id_.emplace(query_id, node_id).second;
|
||||
CHECK(is_inserted);
|
||||
}
|
||||
@ -54,9 +54,9 @@ void FileUploadManager::upload_by_hash(QueryId query_id, const FullLocalFileLoca
|
||||
CHECK(node);
|
||||
node->query_id_ = query_id;
|
||||
auto callback = make_unique<FileHashUploaderCallback>(actor_shared(this, node_id));
|
||||
node->loader_ = create_actor<FileHashUploader>("HashUploader", local_location, size, std::move(callback));
|
||||
node->hash_uploader_ = create_actor<FileHashUploader>("HashUploader", local_location, size, std::move(callback));
|
||||
send_closure(upload_resource_manager_, &ResourceManager::register_worker,
|
||||
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
|
||||
ActorShared<FileLoaderActor>(node->hash_uploader_.get(), static_cast<uint64>(-1)), priority);
|
||||
bool is_inserted = query_id_to_node_id_.emplace(query_id, node_id).second;
|
||||
CHECK(is_inserted);
|
||||
}
|
||||
@ -73,7 +73,11 @@ void FileUploadManager::update_priority(QueryId query_id, int8 priority) {
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
send_closure(node->loader_, &FileLoaderActor::update_priority, priority);
|
||||
if (!node->uploader_.empty()) {
|
||||
send_closure(node->uploader_, &FileLoaderActor::update_priority, priority);
|
||||
} else {
|
||||
send_closure(node->hash_uploader_, &FileLoaderActor::update_priority, priority);
|
||||
}
|
||||
}
|
||||
|
||||
void FileUploadManager::cancel(QueryId query_id) {
|
||||
@ -96,14 +100,17 @@ void FileUploadManager::update_local_file_location(QueryId query_id, const Local
|
||||
return;
|
||||
}
|
||||
auto node = nodes_container_.get(it->second);
|
||||
if (node == nullptr) {
|
||||
if (node == nullptr || node->uploader_.empty()) {
|
||||
return;
|
||||
}
|
||||
send_closure(node->loader_, &FileLoaderActor::update_local_file_location, local);
|
||||
send_closure(node->uploader_, &FileUploader::update_local_file_location, local);
|
||||
}
|
||||
|
||||
void FileUploadManager::hangup() {
|
||||
nodes_container_.for_each([](auto query_id, auto &node) { node.loader_.reset(); });
|
||||
nodes_container_.for_each([](auto query_id, auto &node) {
|
||||
node.uploader_.reset();
|
||||
node.hash_uploader_.reset();
|
||||
});
|
||||
stop_flag_ = true;
|
||||
loop();
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ class FileUploadManager final : public Actor {
|
||||
private:
|
||||
struct Node {
|
||||
QueryId query_id_;
|
||||
ActorOwn<FileLoaderActor> loader_;
|
||||
ActorOwn<FileUploader> uploader_;
|
||||
ActorOwn<FileHashUploader> hash_uploader_;
|
||||
};
|
||||
using NodeId = uint64;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class FileUploader final : public FileLoaderActor {
|
||||
|
||||
void update_resources(const ResourceState &other) final;
|
||||
|
||||
void update_local_file_location(const LocalFileLocation &local) final;
|
||||
void update_local_file_location(const LocalFileLocation &local);
|
||||
|
||||
void update_downloaded_part(int64 offset, int64 limit, int64 max_resource_limit) {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user