2018-04-28 22:22:28 +02:00
|
|
|
//
|
2018-12-31 23:02:34 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
2018-04-28 22:22:28 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/actor/PromiseFuture.h"
|
|
|
|
|
|
|
|
#include "td/db/binlog/BinlogHelper.h"
|
|
|
|
|
|
|
|
#include "td/telegram/Global.h"
|
|
|
|
#include "td/telegram/TdDb.h"
|
|
|
|
|
2019-02-12 22:26:36 +01:00
|
|
|
#include "td/utils/common.h"
|
2018-04-28 22:22:28 +02:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2019-04-13 19:07:02 +02:00
|
|
|
#define get_erase_logevent_promise(...) get_erase_logevent_promise_impl(__FILE__, __LINE__, __VA_ARGS__)
|
|
|
|
|
|
|
|
inline Promise<Unit> get_erase_logevent_promise_impl(const char *file, int32 line, uint64 logevent_id,
|
|
|
|
Promise<Unit> promise = Promise<Unit>()) {
|
2018-04-28 22:22:28 +02:00
|
|
|
if (logevent_id == 0) {
|
2018-05-07 19:20:20 +02:00
|
|
|
return promise;
|
2018-04-28 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
2019-04-13 19:07:02 +02:00
|
|
|
return PromiseCreator::lambda([file, line, logevent_id, promise = std::move(promise)](Result<Unit> result) mutable {
|
2018-04-28 22:22:28 +02:00
|
|
|
if (!G()->close_flag()) {
|
2019-04-21 18:05:19 +02:00
|
|
|
binlog_erase(G()->get_td_db_impl(file, line)->get_binlog_impl(file, line), logevent_id);
|
2018-04-28 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
promise.set_result(std::move(result));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|