Remove fileTypeSecureEncrypted.

GitOrigin-RevId: 33adf461aeea26cf5c4cbb1d28ade3a258b61126
This commit is contained in:
levlam 2018-04-27 11:00:56 +03:00
parent 357ba6640a
commit 62d668674b
10 changed files with 50 additions and 24 deletions

View File

@ -1804,9 +1804,6 @@ fileTypeSecretThumbnail = FileType;
//@description The file is a file from Secure storage used for storing Telegram Passport files
fileTypeSecure = FileType;
//@description The file is an encrypted file from Secure storage used for storing Telegram Passport files; for bots only
fileTypeSecureEncrypted = FileType;
//@description The file is a sticker
fileTypeSticker = FileType;

Binary file not shown.

View File

@ -38,7 +38,7 @@ void CallManager::update_call(Update call) {
auto actor = get_call_actor(info.call_id);
if (actor.empty()) {
LOG(WARNING) << "Drop update: " << to_string(call);
LOG(INFO) << "Drop update: " << to_string(call);
}
send_closure(actor, &CallActor::update_call, std::move(call->phone_call_));
}

View File

@ -1732,6 +1732,7 @@ class CliClient final : public Actor {
types.push_back(make_tl_object<td_api::fileTypeAudio>());
types.push_back(make_tl_object<td_api::fileTypeAnimation>());
types.push_back(make_tl_object<td_api::fileTypeVideoNote>());
types.push_back(make_tl_object<td_api::fileTypeSecure>());
send_request(make_tl_object<td_api::optimizeStorage>(0, -1, -1, 0, std::move(types), as_chat_ids(args, ','),
as_chat_ids(""), 20));
} else if (op == "network") {
@ -2026,7 +2027,7 @@ class CliClient final : public Actor {
}
} else if (op == "cdf") {
send_request(make_tl_object<td_api::cancelDownloadFile>(as_file_id(args), true));
} else if (op == "uf" || op == "ufs" || op == "ufse" || op == "ufsr") {
} else if (op == "uf" || op == "ufs" || op == "ufse") {
string file_path;
string priority;
std::tie(file_path, priority) = split(args);
@ -2039,9 +2040,6 @@ class CliClient final : public Actor {
type = make_tl_object<td_api::fileTypeSecret>();
}
if (op == "ufse") {
type = make_tl_object<td_api::fileTypeSecureEncrypted>();
}
if (op == "ufsr") {
type = make_tl_object<td_api::fileTypeSecure>();
}

View File

@ -138,10 +138,10 @@ Result<string> search_file(CSlice dir, CSlice name, int64 expected_size) {
return res;
}
const char *file_type_name[file_type_size] = {"thumbnails", "profile_photos", "photos", "voice",
"videos", "documents", "secret", "temp",
"stickers", "music", "animations", "secret_thumbnails",
"wallpapers", "video_notes", "passport_temp", "passport"};
const char *file_type_name[file_type_size] = {"thumbnails", "profile_photos", "photos", "voice",
"videos", "documents", "secret", "temp",
"stickers", "music", "animations", "secret_thumbnails",
"wallpapers", "video_notes", "passport", "passport"};
string get_file_base_dir(const FileDirType &file_dir_type) {
switch (file_dir_type) {

View File

@ -83,8 +83,6 @@ inline FileType from_td_api(const td_api::FileType &file_type) {
return FileType::VideoNote;
case td_api::fileTypeSecure::ID:
return FileType::Secure;
case td_api::fileTypeSecureEncrypted::ID:
return FileType::SecureRaw;
case td_api::fileTypeNone::ID:
return FileType::None;
default:
@ -126,7 +124,8 @@ inline tl_object_ptr<td_api::FileType> as_td_api(FileType file_type) {
case FileType::Secure:
return make_tl_object<td_api::fileTypeSecure>();
case FileType::SecureRaw:
return make_tl_object<td_api::fileTypeSecureEncrypted>();
UNREACHABLE();
return make_tl_object<td_api::fileTypeSecure>();
case FileType::None:
return make_tl_object<td_api::fileTypeNone>();
default:

View File

@ -122,14 +122,30 @@ void FileStats::apply_dialog_limit(int32 limit) {
tl_object_ptr<td_api::storageStatisticsByChat> as_td_api(DialogId dialog_id,
const FileStats::StatByType &stat_by_type) {
auto stats = make_tl_object<td_api::storageStatisticsByChat>(dialog_id.get(), 0, 0, Auto());
int64 secure_raw_size = 0;
int32 secure_raw_cnt = 0;
for (size_t i = 0; i < file_type_size; i++) {
if (stat_by_type[i].size == 0) {
FileType file_type = static_cast<FileType>(i);
auto size = stat_by_type[i].size;
auto cnt = stat_by_type[i].cnt;
if (file_type == FileType::SecureRaw) {
secure_raw_size = size;
secure_raw_cnt = cnt;
continue;
}
stats->size_ += stat_by_type[i].size;
stats->count_ += stat_by_type[i].cnt;
stats->by_file_type_.push_back(make_tl_object<td_api::storageStatisticsByFileType>(
as_td_api(FileType(i)), stat_by_type[i].size, stat_by_type[i].cnt));
if (file_type == FileType::Secure) {
size += secure_raw_size;
cnt += secure_raw_cnt;
}
if (size == 0) {
continue;
}
stats->size_ += size;
stats->count_ += cnt;
stats->by_file_type_.push_back(
make_tl_object<td_api::storageStatisticsByFileType>(as_td_api(file_type), size, cnt));
}
return stats;
}

View File

@ -92,6 +92,9 @@ template <class CallbackT>
Status scan_fs(CallbackT &&callback) {
for (int i = 0; i < file_type_size; i++) {
auto file_type = static_cast<FileType>(i);
if (file_type == FileType::SecureRaw) {
continue;
}
auto files_dir = get_files_dir(file_type);
td::walk_path(files_dir, [&](CSlice path, bool is_dir) {
if (is_dir) {

View File

@ -56,7 +56,10 @@ void NetStatsManager::init() {
}
};
for_each_stat([&](NetStatsInfo &stat, size_t id, CSlice name, FileType) {
for_each_stat([&](NetStatsInfo &stat, size_t id, CSlice name, FileType file_type) {
if (file_type == FileType::SecureRaw) {
id++;
}
stat.key = "net_stats_" + name.str();
stat.stats.set_callback(std::make_unique<NetStatsInternalCallback>(actor_id(this), id));
});
@ -107,6 +110,10 @@ void NetStatsManager::get_network_stats(bool current, Promise<NetworkStats> prom
entry.is_call = true;
result.entries.push_back(std::move(entry));
} else if (file_type != FileType::None) {
if (file_type == FileType::SecureRaw) {
return;
}
if (total_files.read_size != 0) {
entry.rx = static_cast<int64>(static_cast<double>(total.read_size) *
(static_cast<double>(entry.rx) / static_cast<double>(total_files.read_size)));
@ -182,7 +189,11 @@ void NetStatsManager::add_network_stats_impl(NetStatsInfo &info, const NetworkSt
}
void NetStatsManager::start_up() {
for_each_stat([&](NetStatsInfo &info, size_t id, CSlice name, FileType) {
for_each_stat([&](NetStatsInfo &info, size_t id, CSlice name, FileType file_type) {
if (file_type == FileType::SecureRaw) {
return;
}
for (size_t net_type_i = 0; net_type_i < net_type_size(); net_type_i++) {
auto net_type = NetType(net_type_i);
auto key = PSTRING() << info.key << "#" << net_type_string(net_type);
@ -237,7 +248,9 @@ std::shared_ptr<NetStatsCallback> NetStatsManager::get_media_stats_callback() co
}
std::vector<std::shared_ptr<NetStatsCallback>> NetStatsManager::get_file_stats_callbacks() const {
return transform(files_stats_, [](auto &stat) { return stat.stats.get_callback(); });
auto result = transform(files_stats_, [](auto &stat) { return stat.stats.get_callback(); });
result[static_cast<int32>(FileType::SecureRaw)] = result[static_cast<int32>(FileType::Secure)];
return result;
}
void NetStatsManager::update(NetStatsInfo &info, bool force_save) {

View File

@ -53,7 +53,7 @@ struct NetworkStats {
result->since_date_ = since;
result->entries_.reserve(entries.size());
for (const auto &entry : entries) {
if (entry.rx != 0 || entry.tx != 0) {
if ((entry.rx != 0 || entry.tx != 0) && entry.file_type != FileType::SecureRaw) {
result->entries_.push_back(entry.as_td_api());
}
}