FileManager: attempt to close ForceUpoadActor

GitOrigin-RevId: 5c53784b7b49c41347477c2f7808cc2845d12463
This commit is contained in:
Arseny Smirnov 2020-08-13 20:04:06 +03:00
parent cecea2ba08
commit 3b18309e80

View File

@ -2330,19 +2330,25 @@ class FileManager::ForceUploadActor : public Actor {
explicit UploadCallback(ActorId<ForceUploadActor> callback) : callback_(std::move(callback)) { explicit UploadCallback(ActorId<ForceUploadActor> callback) : callback_(std::move(callback)) {
} }
void on_upload_ok(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file) override { void on_upload_ok(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file) override {
send_closure(callback_, &ForceUploadActor::on_upload_ok, std::move(input_file)); send_closure(std::move(callback_), &ForceUploadActor::on_upload_ok, std::move(input_file));
} }
void on_upload_encrypted_ok(FileId file_id, tl_object_ptr<telegram_api::InputEncryptedFile> input_file) override { void on_upload_encrypted_ok(FileId file_id, tl_object_ptr<telegram_api::InputEncryptedFile> input_file) override {
send_closure(callback_, &ForceUploadActor::on_upload_encrypted_ok, std::move(input_file)); send_closure(std::move(callback_), &ForceUploadActor::on_upload_encrypted_ok, std::move(input_file));
} }
void on_upload_secure_ok(FileId file_id, tl_object_ptr<telegram_api::InputSecureFile> input_file) override { void on_upload_secure_ok(FileId file_id, tl_object_ptr<telegram_api::InputSecureFile> input_file) override {
send_closure(callback_, &ForceUploadActor::on_upload_secure_ok, std::move(input_file)); send_closure(std::move(callback_), &ForceUploadActor::on_upload_secure_ok, std::move(input_file));
} }
void on_upload_error(FileId file_id, Status error) override { void on_upload_error(FileId file_id, Status error) override {
send_closure(callback_, &ForceUploadActor::on_upload_error, std::move(error)); send_closure(std::move(callback_), &ForceUploadActor::on_upload_error, std::move(error));
}
~UploadCallback() {
if (callback_.empty()) {
return;
}
send_closure(std::move(callback_), &ForceUploadActor::on_upload_error, td::Status::Error("Cancelled"));
} }
private: private:
@ -2408,6 +2414,9 @@ class FileManager::ForceUploadActor : public Actor {
if (is_active_) { if (is_active_) {
return; return;
} }
if (G()->close_flag()) {
return stop();
}
is_active_ = true; is_active_ = true;
attempt_++; attempt_++;