Skip to content

Commit

Permalink
Add file_upload_id validness checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Oct 5, 2024
1 parent 3478c2d commit 15b86a1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions td/telegram/BackgroundManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ void BackgroundManager::upload_background_file(FileId file_id, const BackgroundT
bool for_dark_theme,
Promise<td_api::object_ptr<td_api::background>> &&promise) {
auto file_upload_id = FileUploadId{file_id, FileManager::get_internal_upload_id()};
CHECK(file_upload_id.is_valid());
bool is_inserted = being_uploaded_files_
.emplace(file_upload_id, UploadedFileInfo(type, dialog_id, for_dark_theme, std::move(promise)))
.second;
Expand Down
1 change: 1 addition & 0 deletions td/telegram/StickersManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8169,6 +8169,7 @@ void StickersManager::upload_sticker_file(UserId user_id, FileId file_id, Promis
}

FileUploadId file_upload_id{file_id, FileManager::get_internal_upload_id()};
CHECK(file_upload_id.is_valid());
being_uploaded_files_[file_upload_id] = {user_id, std::move(promise)};
LOG(INFO) << "Ask to upload sticker " << file_upload_id;
td_->file_manager_->upload(file_upload_id, upload_sticker_file_callback_, 2, 0);
Expand Down
1 change: 1 addition & 0 deletions td/telegram/StoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5277,6 +5277,7 @@ void StoryManager::do_send_story(unique_ptr<PendingStory> &&pending_story, vecto
if (!pending_story->story_id_.is_server()) {
being_uploaded_file_upload_ids_[story_full_id] = file_upload_id;
}
CHECK(file_upload_id.is_valid());
bool is_inserted = being_uploaded_files_.emplace(file_upload_id, std::move(pending_story)).second;
CHECK(is_inserted);
// need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_
Expand Down

0 comments on commit 15b86a1

Please sign in to comment.