Store link to parent in FileReferenceManager.
This commit is contained in:
parent
491e50ac4b
commit
2865be8dd7
@ -32,10 +32,17 @@ namespace td {
|
|||||||
|
|
||||||
int VERBOSITY_NAME(file_references) = VERBOSITY_NAME(INFO);
|
int VERBOSITY_NAME(file_references) = VERBOSITY_NAME(INFO);
|
||||||
|
|
||||||
|
FileReferenceManager::FileReferenceManager(ActorShared<> parent) : parent_(std::move(parent)) {
|
||||||
|
}
|
||||||
|
|
||||||
FileReferenceManager::~FileReferenceManager() {
|
FileReferenceManager::~FileReferenceManager() {
|
||||||
Scheduler::instance()->destroy_on_scheduler(G()->get_gc_scheduler_id(), file_sources_);
|
Scheduler::instance()->destroy_on_scheduler(G()->get_gc_scheduler_id(), file_sources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileReferenceManager::tear_down() {
|
||||||
|
parent_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
bool FileReferenceManager::is_file_reference_error(const Status &error) {
|
bool FileReferenceManager::is_file_reference_error(const Status &error) {
|
||||||
return error.is_error() && error.code() == 400 && begins_with(error.message(), "FILE_REFERENCE_");
|
return error.is_error() && error.code() == 400 && begins_with(error.message(), "FILE_REFERENCE_");
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ extern int VERBOSITY_NAME(file_references);
|
|||||||
|
|
||||||
class FileReferenceManager final : public Actor {
|
class FileReferenceManager final : public Actor {
|
||||||
public:
|
public:
|
||||||
FileReferenceManager() = default;
|
explicit FileReferenceManager(ActorShared<> parent);
|
||||||
FileReferenceManager(const FileReferenceManager &) = delete;
|
FileReferenceManager(const FileReferenceManager &) = delete;
|
||||||
FileReferenceManager &operator=(const FileReferenceManager &) = delete;
|
FileReferenceManager &operator=(const FileReferenceManager &) = delete;
|
||||||
FileReferenceManager(FileReferenceManager &&) = delete;
|
FileReferenceManager(FileReferenceManager &&) = delete;
|
||||||
@ -173,6 +173,8 @@ class FileReferenceManager final : public Actor {
|
|||||||
|
|
||||||
FlatHashMap<NodeId, Node, FileIdHash> nodes_;
|
FlatHashMap<NodeId, Node, FileIdHash> nodes_;
|
||||||
|
|
||||||
|
ActorShared<> parent_;
|
||||||
|
|
||||||
void run_node(NodeId node);
|
void run_node(NodeId node);
|
||||||
void send_query(Destination dest, FileSourceId file_source_id);
|
void send_query(Destination dest, FileSourceId file_source_id);
|
||||||
Destination on_query_result(Destination dest, FileSourceId file_source_id, Status status, int32 sub = 0);
|
Destination on_query_result(Destination dest, FileSourceId file_source_id, Status status, int32 sub = 0);
|
||||||
@ -181,6 +183,8 @@ class FileReferenceManager final : public Actor {
|
|||||||
FileSourceId add_file_source_id(T source, Slice source_str);
|
FileSourceId add_file_source_id(T source, Slice source_str);
|
||||||
|
|
||||||
FileSourceId get_current_file_source_id() const;
|
FileSourceId get_current_file_source_id() const;
|
||||||
|
|
||||||
|
void tear_down() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -489,6 +489,7 @@ void SetSecureValue::load_secret() {
|
|||||||
send_closure(actor_id, &SetSecureValue::on_secret, std::move(r_secret), true);
|
send_closure(actor_id, &SetSecureValue::on_secret, std::move(r_secret), true);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSecureValue::cancel_upload() {
|
void SetSecureValue::cancel_upload() {
|
||||||
upload_generation_++;
|
upload_generation_++;
|
||||||
auto *file_manager = G()->td().get_actor_unsafe()->file_manager_.get();
|
auto *file_manager = G()->td().get_actor_unsafe()->file_manager_.get();
|
||||||
|
@ -3939,7 +3939,7 @@ void Td::init_file_manager() {
|
|||||||
file_manager_->init_actor();
|
file_manager_->init_actor();
|
||||||
G()->set_file_manager(file_manager_actor_.get());
|
G()->set_file_manager(file_manager_actor_.get());
|
||||||
|
|
||||||
file_reference_manager_ = make_unique<FileReferenceManager>();
|
file_reference_manager_ = make_unique<FileReferenceManager>(create_reference());
|
||||||
file_reference_manager_actor_ = register_actor("FileReferenceManager", file_reference_manager_.get());
|
file_reference_manager_actor_ = register_actor("FileReferenceManager", file_reference_manager_.get());
|
||||||
G()->set_file_reference_manager(file_reference_manager_actor_.get());
|
G()->set_file_reference_manager(file_reference_manager_actor_.get());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user