Add language_pack_database_size to storageStatisticsFast.
GitOrigin-RevId: 6c11b5b88edd470da8abe2a0459a9067c3cb6d21
This commit is contained in:
parent
be06d10b39
commit
2898c8909b
@ -14,6 +14,7 @@
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/db/SqliteConnectionSafe.h"
|
||||
#include "td/db/SqliteDb.h"
|
||||
|
||||
#include "td/utils/benchmark.h"
|
||||
#include "td/utils/buffer.h"
|
||||
|
@ -2264,8 +2264,9 @@ storageStatisticsByChat chat_id:int53 size:int53 count:int32 by_file_type:vector
|
||||
//@description Contains the exact storage usage statistics split by chats and file type @size Total size of files @count Total number of files @by_chat Statistics split by chats
|
||||
storageStatistics size:int53 count:int32 by_chat:vector<storageStatisticsByChat> = StorageStatistics;
|
||||
|
||||
//@description Contains approximate storage usage statistics, excluding files of unknown file type @files_size Approximate total size of files @file_count Approximate number of files @database_size Size of the database @log_size Size of the TDLib interna log
|
||||
storageStatisticsFast files_size:int53 file_count:int32 database_size:int53 log_size:int53 = StorageStatisticsFast;
|
||||
//@description Contains approximate storage usage statistics, excluding files of unknown file type @files_size Approximate total size of files @file_count Approximate number of files
|
||||
//@database_size Size of the database @language_pack_database_size Size of the language pack database @log_size Size of the TDLib internal log
|
||||
storageStatisticsFast files_size:int53 file_count:int32 database_size:int53 language_pack_database_size:int53 log_size:int53 = StorageStatisticsFast;
|
||||
|
||||
//@description Contains database statistics
|
||||
//@statistics Database statistics in an unspecified human-readable format
|
||||
|
Binary file not shown.
@ -15,6 +15,8 @@
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
|
||||
#include "td/db/SqliteDb.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/port/Clocks.h"
|
||||
@ -68,7 +70,8 @@ void StorageManager::get_storage_stats(int32 dialog_limit, Promise<FileStats> pr
|
||||
}
|
||||
|
||||
void StorageManager::get_storage_stats_fast(Promise<FileStatsFast> promise) {
|
||||
promise.set_value(FileStatsFast(fast_stat_.size, fast_stat_.cnt, get_database_size(), get_log_size()));
|
||||
promise.set_value(FileStatsFast(fast_stat_.size, fast_stat_.cnt, get_database_size(),
|
||||
get_language_pack_database_size(), get_log_size()));
|
||||
}
|
||||
|
||||
void StorageManager::get_database_stats(Promise<DatabaseStats> promise) {
|
||||
@ -160,6 +163,15 @@ int64 StorageManager::get_database_size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
int64 StorageManager::get_language_pack_database_size() {
|
||||
int64 size = 0;
|
||||
auto path = G()->shared_config().get_option_string("language_pack_database_path");
|
||||
if (!path.empty()) {
|
||||
SqliteDb::with_db_path(path, [&size](CSlice path) { size += get_file_size(path); });
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int64 StorageManager::get_log_size() {
|
||||
int64 size = 0;
|
||||
for (auto &log_path : log_interface->get_file_paths()) {
|
||||
|
@ -62,6 +62,7 @@ class StorageManager : public Actor {
|
||||
void save_fast_stat();
|
||||
void load_fast_stat();
|
||||
static int64 get_database_size();
|
||||
static int64 get_language_pack_database_size();
|
||||
static int64 get_log_size();
|
||||
static int64 get_file_size(CSlice path);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "td/db/binlog/ConcurrentBinlog.h"
|
||||
#include "td/db/BinlogKeyValue.h"
|
||||
#include "td/db/SqliteConnectionSafe.h"
|
||||
#include "td/db/SqliteDb.h"
|
||||
#include "td/db/SqliteKeyValue.h"
|
||||
#include "td/db/SqliteKeyValueAsync.h"
|
||||
#include "td/db/SqliteKeyValueSafe.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
#include "td/db/SqliteConnectionSafe.h"
|
||||
#include "td/db/SqliteDb.h"
|
||||
#include "td/db/SqliteKeyValue.h"
|
||||
#include "td/db/SqliteKeyValueSafe.h"
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
namespace td {
|
||||
|
||||
tl_object_ptr<td_api::storageStatisticsFast> FileStatsFast::as_td_api() const {
|
||||
return make_tl_object<td_api::storageStatisticsFast>(size, count, database_size, log_size);
|
||||
return make_tl_object<td_api::storageStatisticsFast>(size, count, database_size, language_pack_database_size,
|
||||
log_size);
|
||||
}
|
||||
|
||||
void FileStats::add(StatByType &by_type, FileType file_type, int64 size) {
|
||||
|
@ -56,9 +56,14 @@ struct FileStatsFast {
|
||||
int64 size{0};
|
||||
int32 count{0};
|
||||
int64 database_size{0};
|
||||
int64 language_pack_database_size{0};
|
||||
int64 log_size{0};
|
||||
FileStatsFast(int64 size, int32 count, int64 database_size, int64 log_size)
|
||||
: size(size), count(count), database_size(database_size), log_size(log_size) {
|
||||
FileStatsFast(int64 size, int32 count, int64 database_size, int64 language_pack_database_size, int64 log_size)
|
||||
: size(size)
|
||||
, count(count)
|
||||
, database_size(database_size)
|
||||
, language_pack_database_size(language_pack_database_size)
|
||||
, log_size(log_size) {
|
||||
}
|
||||
tl_object_ptr<td_api::storageStatisticsFast> as_td_api() const;
|
||||
};
|
||||
|
@ -83,4 +83,5 @@ class SqliteDb {
|
||||
|
||||
bool is_encrypted();
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/db/BinlogKeyValue.h"
|
||||
#include "td/db/SeqKeyValue.h"
|
||||
#include "td/db/SqliteConnectionSafe.h"
|
||||
#include "td/db/SqliteDb.h"
|
||||
#include "td/db/SqliteKeyValue.h"
|
||||
#include "td/db/SqliteKeyValueSafe.h"
|
||||
#include "td/db/TsSeqKeyValue.h"
|
||||
|
Loading…
Reference in New Issue
Block a user