Add Global::keep_media_order.

This commit is contained in:
levlam 2023-03-14 01:48:32 +03:00
parent d6faa001e2
commit d132c3e50d
3 changed files with 10 additions and 7 deletions

View File

@ -398,6 +398,10 @@ class Global final : public ActorContext {
bool use_message_database() const; bool use_message_database() const;
bool keep_media_order() const {
return use_file_database();
}
int32 get_gc_scheduler_id() const { int32 get_gc_scheduler_id() const {
return gc_scheduler_id_; return gc_scheduler_id_;
} }

View File

@ -26332,7 +26332,7 @@ void MessagesManager::cancel_send_message_query(DialogId dialog_id, Message *m)
m->message_id, Status::OK()); m->message_id, Status::OK());
} }
if (!m->message_id.is_scheduled() && G()->use_file_database() && !m->is_copy) { // ResourceManager::Mode::Baseline if (!m->message_id.is_scheduled() && G()->keep_media_order() && !m->is_copy) {
auto queue_id = ChainId(dialog_id, m->content->get_type()).get(); auto queue_id = ChainId(dialog_id, m->content->get_type()).get();
if (queue_id & 1) { if (queue_id & 1) {
auto queue_it = yet_unsent_media_queues_.find(queue_id); auto queue_it = yet_unsent_media_queues_.find(queue_id);
@ -27481,7 +27481,7 @@ void MessagesManager::on_media_message_ready_to_send(DialogId dialog_id, Message
Promise<Message *> &&promise) { Promise<Message *> &&promise) {
LOG(INFO) << "Ready to send " << message_id << " to " << dialog_id; LOG(INFO) << "Ready to send " << message_id << " to " << dialog_id;
CHECK(promise); CHECK(promise);
if (!G()->use_file_database() || message_id.is_scheduled()) { // ResourceManager::Mode::Greedy if (!G()->keep_media_order() || message_id.is_scheduled()) {
auto m = get_message({dialog_id, message_id}); auto m = get_message({dialog_id, message_id});
if (m != nullptr) { if (m != nullptr) {
promise.set_value(std::move(m)); promise.set_value(std::move(m));
@ -36027,7 +36027,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
} }
} }
if (G()->use_file_database() && message_id.is_yet_unsent() && !message->via_bot_user_id.is_valid() && if (G()->keep_media_order() && message_id.is_yet_unsent() && !message->via_bot_user_id.is_valid() &&
!message->hide_via_bot && !message->is_copy) { !message->hide_via_bot && !message->is_copy) {
auto queue_id = ChainId(dialog_id, message_content_type).get(); auto queue_id = ChainId(dialog_id, message_content_type).get();
if (queue_id & 1) { if (queue_id & 1) {

View File

@ -23,10 +23,9 @@ FileLoadManager::FileLoadManager(ActorShared<Callback> callback, ActorShared<> p
void FileLoadManager::start_up() { void FileLoadManager::start_up() {
constexpr int64 MAX_UPLOAD_RESOURCE_LIMIT = 4 << 20; constexpr int64 MAX_UPLOAD_RESOURCE_LIMIT = 4 << 20;
upload_resource_manager_ = create_actor<ResourceManager>("UploadResourceManager", MAX_UPLOAD_RESOURCE_LIMIT, upload_resource_manager_ = create_actor<ResourceManager>(
!G()->use_file_database() /*tdlib_engine*/ "UploadResourceManager", MAX_UPLOAD_RESOURCE_LIMIT,
? ResourceManager::Mode::Greedy !G()->keep_media_order() ? ResourceManager::Mode::Greedy : ResourceManager::Mode::Baseline);
: ResourceManager::Mode::Baseline);
if (G()->get_option_boolean("is_premium")) { if (G()->get_option_boolean("is_premium")) {
max_download_resource_limit_ *= 8; max_download_resource_limit_ *= 8;
} }