Add separate field for log size in fast storage statistics.
GitOrigin-RevId: 6e76c7ac995db6599a927d54e8d85aed95f020c0
This commit is contained in:
parent
9e8046db1c
commit
e77bbc7ffc
@ -2260,8 +2260,8 @@ 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
|
//@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;
|
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
|
//@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 = StorageStatisticsFast;
|
storageStatisticsFast files_size:int53 file_count:int32 database_size:int53 log_size:int53 = StorageStatisticsFast;
|
||||||
|
|
||||||
//@description Contains database statistics
|
//@description Contains database statistics
|
||||||
//@statistics Database statistics in an unspecified human-readable format
|
//@statistics Database statistics in an unspecified human-readable format
|
||||||
|
Binary file not shown.
@ -70,7 +70,7 @@ void StorageManager::get_storage_stats(int32 dialog_limit, Promise<FileStats> pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StorageManager::get_storage_stats_fast(Promise<FileStatsFast> promise) {
|
void StorageManager::get_storage_stats_fast(Promise<FileStatsFast> promise) {
|
||||||
promise.set_value(FileStatsFast(fast_stat_.size, fast_stat_.cnt, get_db_size()));
|
promise.set_value(FileStatsFast(fast_stat_.size, fast_stat_.cnt, get_database_size(), get_log_size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageManager::get_database_stats(Promise<DatabaseStats> promise) {
|
void StorageManager::get_database_stats(Promise<DatabaseStats> promise) {
|
||||||
@ -145,21 +145,27 @@ void StorageManager::on_all_files(Result<FileStats> r_file_stats, bool dummy) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 StorageManager::get_db_size() {
|
int64 StorageManager::get_file_size(CSlice path) {
|
||||||
|
auto r_info = stat(path);
|
||||||
|
if (r_info.is_error()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto size = r_info.ok().size_;
|
||||||
|
LOG(DEBUG) << "Add file \"" << path << "\" of size " << size << " to fast storage statistics";
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 StorageManager::get_database_size() {
|
||||||
int64 size = 0;
|
int64 size = 0;
|
||||||
auto add_path = [&](CSlice path) {
|
G()->td_db()->with_db_path([&size](CSlice path) { size += get_file_size(path); });
|
||||||
TRY_RESULT(info, stat(path));
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(DEBUG) << "Add database file \"" << path << "\" of size " << info.size_
|
int64 StorageManager::get_log_size() {
|
||||||
<< " to database storage size statistics";
|
int64 size = 0;
|
||||||
size += info.size_;
|
|
||||||
|
|
||||||
return Status::OK();
|
|
||||||
};
|
|
||||||
|
|
||||||
G()->td_db()->with_db_path([&](CSlice path) { add_path(path).ignore(); });
|
|
||||||
for (auto &log_path : log_interface->get_file_paths()) {
|
for (auto &log_path : log_interface->get_file_paths()) {
|
||||||
add_path(log_path).ignore();
|
size += get_file_size(log_path);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,9 @@ class StorageManager : public Actor {
|
|||||||
|
|
||||||
void save_fast_stat();
|
void save_fast_stat();
|
||||||
void load_fast_stat();
|
void load_fast_stat();
|
||||||
static int64 get_db_size();
|
static int64 get_database_size();
|
||||||
|
static int64 get_log_size();
|
||||||
|
static int64 get_file_size(CSlice path);
|
||||||
|
|
||||||
// RefCnt
|
// RefCnt
|
||||||
int32 ref_cnt_{1};
|
int32 ref_cnt_{1};
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
tl_object_ptr<td_api::storageStatisticsFast> FileStatsFast::as_td_api() const {
|
tl_object_ptr<td_api::storageStatisticsFast> FileStatsFast::as_td_api() const {
|
||||||
return make_tl_object<td_api::storageStatisticsFast>(size, count, db_size);
|
return make_tl_object<td_api::storageStatisticsFast>(size, count, database_size, log_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStats::add(StatByType &by_type, FileType file_type, int64 size) {
|
void FileStats::add(StatByType &by_type, FileType file_type, int64 size) {
|
||||||
|
@ -55,8 +55,10 @@ struct FullFileInfo {
|
|||||||
struct FileStatsFast {
|
struct FileStatsFast {
|
||||||
int64 size{0};
|
int64 size{0};
|
||||||
int32 count{0};
|
int32 count{0};
|
||||||
int64 db_size{0};
|
int64 database_size{0};
|
||||||
FileStatsFast(int64 size, int32 count, int64 db_size) : size(size), count(count), db_size(db_size) {
|
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) {
|
||||||
}
|
}
|
||||||
tl_object_ptr<td_api::storageStatisticsFast> as_td_api() const;
|
tl_object_ptr<td_api::storageStatisticsFast> as_td_api() const;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user