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 //@description The file is a file from Secure storage used for storing Telegram Passport files
fileTypeSecure = FileType; 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 //@description The file is a sticker
fileTypeSticker = FileType; 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); auto actor = get_call_actor(info.call_id);
if (actor.empty()) { 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_)); 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::fileTypeAudio>());
types.push_back(make_tl_object<td_api::fileTypeAnimation>()); 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::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, ','), send_request(make_tl_object<td_api::optimizeStorage>(0, -1, -1, 0, std::move(types), as_chat_ids(args, ','),
as_chat_ids(""), 20)); as_chat_ids(""), 20));
} else if (op == "network") { } else if (op == "network") {
@ -2026,7 +2027,7 @@ class CliClient final : public Actor {
} }
} else if (op == "cdf") { } else if (op == "cdf") {
send_request(make_tl_object<td_api::cancelDownloadFile>(as_file_id(args), true)); 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 file_path;
string priority; string priority;
std::tie(file_path, priority) = split(args); std::tie(file_path, priority) = split(args);
@ -2039,9 +2040,6 @@ class CliClient final : public Actor {
type = make_tl_object<td_api::fileTypeSecret>(); type = make_tl_object<td_api::fileTypeSecret>();
} }
if (op == "ufse") { if (op == "ufse") {
type = make_tl_object<td_api::fileTypeSecureEncrypted>();
}
if (op == "ufsr") {
type = make_tl_object<td_api::fileTypeSecure>(); type = make_tl_object<td_api::fileTypeSecure>();
} }

View File

@ -141,7 +141,7 @@ Result<string> search_file(CSlice dir, CSlice name, int64 expected_size) {
const char *file_type_name[file_type_size] = {"thumbnails", "profile_photos", "photos", "voice", const char *file_type_name[file_type_size] = {"thumbnails", "profile_photos", "photos", "voice",
"videos", "documents", "secret", "temp", "videos", "documents", "secret", "temp",
"stickers", "music", "animations", "secret_thumbnails", "stickers", "music", "animations", "secret_thumbnails",
"wallpapers", "video_notes", "passport_temp", "passport"}; "wallpapers", "video_notes", "passport", "passport"};
string get_file_base_dir(const FileDirType &file_dir_type) { string get_file_base_dir(const FileDirType &file_dir_type) {
switch (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; return FileType::VideoNote;
case td_api::fileTypeSecure::ID: case td_api::fileTypeSecure::ID:
return FileType::Secure; return FileType::Secure;
case td_api::fileTypeSecureEncrypted::ID:
return FileType::SecureRaw;
case td_api::fileTypeNone::ID: case td_api::fileTypeNone::ID:
return FileType::None; return FileType::None;
default: default:
@ -126,7 +124,8 @@ inline tl_object_ptr<td_api::FileType> as_td_api(FileType file_type) {
case FileType::Secure: case FileType::Secure:
return make_tl_object<td_api::fileTypeSecure>(); return make_tl_object<td_api::fileTypeSecure>();
case FileType::SecureRaw: case FileType::SecureRaw:
return make_tl_object<td_api::fileTypeSecureEncrypted>(); UNREACHABLE();
return make_tl_object<td_api::fileTypeSecure>();
case FileType::None: case FileType::None:
return make_tl_object<td_api::fileTypeNone>(); return make_tl_object<td_api::fileTypeNone>();
default: 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, tl_object_ptr<td_api::storageStatisticsByChat> as_td_api(DialogId dialog_id,
const FileStats::StatByType &stat_by_type) { const FileStats::StatByType &stat_by_type) {
auto stats = make_tl_object<td_api::storageStatisticsByChat>(dialog_id.get(), 0, 0, Auto()); 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++) { 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; continue;
} }
stats->size_ += stat_by_type[i].size; if (file_type == FileType::Secure) {
stats->count_ += stat_by_type[i].cnt; size += secure_raw_size;
stats->by_file_type_.push_back(make_tl_object<td_api::storageStatisticsByFileType>( cnt += secure_raw_cnt;
as_td_api(FileType(i)), stat_by_type[i].size, stat_by_type[i].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; return stats;
} }

View File

@ -92,6 +92,9 @@ template <class CallbackT>
Status scan_fs(CallbackT &&callback) { Status scan_fs(CallbackT &&callback) {
for (int i = 0; i < file_type_size; i++) { for (int i = 0; i < file_type_size; i++) {
auto file_type = static_cast<FileType>(i); auto file_type = static_cast<FileType>(i);
if (file_type == FileType::SecureRaw) {
continue;
}
auto files_dir = get_files_dir(file_type); auto files_dir = get_files_dir(file_type);
td::walk_path(files_dir, [&](CSlice path, bool is_dir) { td::walk_path(files_dir, [&](CSlice path, bool is_dir) {
if (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.key = "net_stats_" + name.str();
stat.stats.set_callback(std::make_unique<NetStatsInternalCallback>(actor_id(this), id)); 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; entry.is_call = true;
result.entries.push_back(std::move(entry)); result.entries.push_back(std::move(entry));
} else if (file_type != FileType::None) { } else if (file_type != FileType::None) {
if (file_type == FileType::SecureRaw) {
return;
}
if (total_files.read_size != 0) { if (total_files.read_size != 0) {
entry.rx = static_cast<int64>(static_cast<double>(total.read_size) * entry.rx = static_cast<int64>(static_cast<double>(total.read_size) *
(static_cast<double>(entry.rx) / static_cast<double>(total_files.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() { 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++) { for (size_t net_type_i = 0; net_type_i < net_type_size(); net_type_i++) {
auto net_type = NetType(net_type_i); auto net_type = NetType(net_type_i);
auto key = PSTRING() << info.key << "#" << net_type_string(net_type); 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 { 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) { void NetStatsManager::update(NetStatsInfo &info, bool force_save) {

View File

@ -53,7 +53,7 @@ struct NetworkStats {
result->since_date_ = since; result->since_date_ = since;
result->entries_.reserve(entries.size()); result->entries_.reserve(entries.size());
for (const auto &entry : entries) { 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()); result->entries_.push_back(entry.as_td_api());
} }
} }