diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 31a3ec2cf..8b20d2830 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -129,10 +129,13 @@ class GetUserStoriesQuery final : public Td::ResultHandler { }; class StoryManager::SendStoryQuery final : public Td::ResultHandler { + FileId file_id_; unique_ptr pending_story_; public: - void send(unique_ptr pending_story, telegram_api::object_ptr input_file) { + void send(FileId file_id, unique_ptr pending_story, + telegram_api::object_ptr input_file) { + file_id_ = file_id; pending_story_ = std::move(pending_story); CHECK(pending_story_ != nullptr); @@ -171,14 +174,19 @@ class StoryManager::SendStoryQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendStoryQuery: " << to_string(ptr); td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); + + td_->file_manager_->delete_partial_remote_location(file_id_); } void on_error(Status status) final { LOG(INFO) << "Receive error for SendStoryQuery: " << status; + if (G()->close_flag() && G()->use_message_database()) { // do not send error, message will be re-sent return; } + + td_->file_manager_->delete_partial_remote_location(file_id_); } }; @@ -589,7 +597,7 @@ void StoryManager::on_upload_story(FileId file_id, telegram_api::object_ptrcreate_handler()->send(std::move(pending_story), std::move(input_file)); + td_->create_handler()->send(file_id, std::move(pending_story), std::move(input_file)); } void StoryManager::on_upload_story_error(FileId file_id, Status status) {