Improve names of FileType::Secure.

This commit is contained in:
levlam 2022-04-25 19:00:40 +03:00
parent 69eb286067
commit 641ee080c1
10 changed files with 36 additions and 35 deletions

View File

@ -548,7 +548,7 @@ void SetSecureValue::start_upload(FileManager *file_manager, FileId &file_id, Se
auto download_file_id = file_manager->dup_file_id(file_id);
file_id =
file_manager
->register_generate(FileType::Secure, FileLocationSource::FromServer, file_view.suggested_path(),
->register_generate(FileType::SecureEncrypted, FileLocationSource::FromServer, file_view.suggested_path(),
PSTRING() << "#file_id#" << download_file_id.get(), DialogId(), file_view.size())
.ok();
}

View File

@ -354,8 +354,8 @@ EncryptedSecureFile get_encrypted_secure_file(FileManager *file_manager,
break;
}
result.file.file_id = file_manager->register_remote(
FullRemoteFileLocation(FileType::Secure, secure_file->id_, secure_file->access_hash_, DcId::internal(dc_id),
""),
FullRemoteFileLocation(FileType::SecureEncrypted, secure_file->id_, secure_file->access_hash_,
DcId::internal(dc_id), ""),
FileLocationSource::FromServer, DialogId(), 0, secure_file->size_, PSTRING() << secure_file->id_ << ".jpg");
result.file.date = secure_file->date_;
if (result.file.date < 0) {
@ -427,12 +427,12 @@ static td_api::object_ptr<td_api::datedFile> get_dated_file_object(FileManager *
LOG(ERROR) << "Have wrong file in get_dated_file_object";
return nullptr;
}
dated_file.file_id =
file_manager->register_remote(FullRemoteFileLocation(FileType::SecureRaw, file_view.remote_location().get_id(),
file_view.remote_location().get_access_hash(),
file_view.remote_location().get_dc_id(), ""),
FileLocationSource::FromServer, DialogId(), file_view.size(),
file_view.expected_size(), file_view.suggested_path());
dated_file.file_id = file_manager->register_remote(
FullRemoteFileLocation(FileType::SecureDecrypted, file_view.remote_location().get_id(),
file_view.remote_location().get_access_hash(), file_view.remote_location().get_dc_id(),
""),
FileLocationSource::FromServer, DialogId(), file_view.size(), file_view.expected_size(),
file_view.suggested_path());
return get_dated_file_object(file_manager, dated_file);
}
@ -843,7 +843,8 @@ static Status check_document_number(string &number) {
}
static Result<DatedFile> get_secure_file(FileManager *file_manager, td_api::object_ptr<td_api::InputFile> &&file) {
TRY_RESULT(file_id, file_manager->get_input_file_id(FileType::Secure, file, DialogId(), false, false, false, true));
TRY_RESULT(file_id,
file_manager->get_input_file_id(FileType::SecureEncrypted, file, DialogId(), false, false, false, true));
DatedFile result;
result.file_id = file_id;
result.date = G()->unix_time();

View File

@ -6575,7 +6575,7 @@ void Td::on_request(uint64 id, td_api::uploadFile &request) {
auto file_type = request.file_type_ == nullptr ? FileType::Temp : get_file_type(*request.file_type_);
bool is_secret = file_type == FileType::Encrypted || file_type == FileType::EncryptedThumbnail;
bool is_secure = file_type == FileType::Secure;
bool is_secure = file_type == FileType::SecureEncrypted;
auto r_file_id = file_manager_->get_input_file_id(file_type, request.file_, DialogId(), false, is_secret,
!is_secure && !is_secret, is_secure);
if (r_file_id.is_error()) {

View File

@ -63,7 +63,7 @@ Result<FileLoader::FileInfo> FileDownloader::init() {
if (encryption_key_.is_secure() && !encryption_key_.has_value_hash()) {
LOG(ERROR) << "Can't download Secure file with unknown value_hash";
}
if (remote_.file_type_ == FileType::Secure) {
if (remote_.file_type_ == FileType::SecureEncrypted) {
size_ = 0;
}
int32 part_size = 0;

View File

@ -361,13 +361,13 @@ class FullRemoteFileLocation {
return file_type_ == FileType::Encrypted;
}
bool is_encrypted_secure() const {
return file_type_ == FileType::Secure;
return file_type_ == FileType::SecureEncrypted;
}
bool is_encrypted_any() const {
return is_encrypted_secret() || is_encrypted_secure();
}
bool is_secure() const {
return file_type_ == FileType::SecureRaw || file_type_ == FileType::Secure;
return file_type_ == FileType::SecureDecrypted || file_type_ == FileType::SecureEncrypted;
}
bool is_document() const {
return is_common() && !is_secure() && !is_encrypted_secret();

View File

@ -923,8 +923,8 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
case FileType::Encrypted:
case FileType::Temp:
case FileType::EncryptedThumbnail:
case FileType::Secure:
case FileType::SecureRaw:
case FileType::SecureEncrypted:
case FileType::SecureDecrypted:
case FileType::DocumentAsFile:
case FileType::CallLog:
break;
@ -2796,7 +2796,7 @@ void FileManager::run_upload(FileNodePtr node, std::vector<int> bad_parts) {
<< ", generate_id = " << node->generate_id_ << ", generate_was_update = " << node->generate_was_update_;
return;
}
if (file_view.has_generate_location() && file_view.generate_location().file_type_ == FileType::Secure) {
if (file_view.has_generate_location() && file_view.generate_location().file_type_ == FileType::SecureEncrypted) {
// Can't upload secure file before its size is known
LOG(INFO) << "Can't upload secure file " << node->main_file_id_ << " before it's size is known";
return;
@ -2815,7 +2815,7 @@ void FileManager::run_upload(FileNodePtr node, std::vector<int> bad_parts) {
}
// create encryption key if necessary
if (file_view.has_local_location() && file_view.local_location().file_type_ == FileType::Secure &&
if (file_view.has_local_location() && file_view.local_location().file_type_ == FileType::SecureEncrypted &&
file_view.encryption_key().empty()) {
CHECK(!node->file_ids_.empty());
bool success = set_encryption_key(node->file_ids_[0], FileEncryptionKey::create_secure_key());
@ -3148,7 +3148,7 @@ Result<FileId> FileManager::get_input_file_id(FileType type, const tl_object_ptr
get_by_hash = false;
}
auto new_type = is_encrypted ? FileType::Encrypted : (is_secure ? FileType::Secure : type);
auto new_type = is_encrypted ? FileType::Encrypted : (is_secure ? FileType::SecureEncrypted : type);
auto r_file_id = [&]() -> Result<FileId> {
switch (file->get_id()) {

View File

@ -305,10 +305,10 @@ class FileView {
return get_type() == FileType::Encrypted;
}
bool is_encrypted_secure() const {
return get_type() == FileType::Secure;
return get_type() == FileType::SecureEncrypted;
}
bool is_secure() const {
return get_type() == FileType::Secure || get_type() == FileType::SecureRaw;
return get_type() == FileType::SecureEncrypted || get_type() == FileType::SecureDecrypted;
}
bool is_encrypted_any() const {
return is_encrypted_secret() || is_encrypted_secure();

View File

@ -39,7 +39,7 @@ FileType get_file_type(const td_api::FileType &file_type) {
case td_api::fileTypeVideoNote::ID:
return FileType::VideoNote;
case td_api::fileTypeSecure::ID:
return FileType::Secure;
return FileType::SecureEncrypted;
case td_api::fileTypeNotificationSound::ID:
return FileType::Ringtone;
case td_api::fileTypeNone::ID:
@ -80,9 +80,9 @@ tl_object_ptr<td_api::FileType> get_file_type_object(FileType file_type) {
return make_tl_object<td_api::fileTypeWallpaper>();
case FileType::VideoNote:
return make_tl_object<td_api::fileTypeVideoNote>();
case FileType::Secure:
case FileType::SecureEncrypted:
return make_tl_object<td_api::fileTypeSecure>();
case FileType::SecureRaw:
case FileType::SecureDecrypted:
UNREACHABLE();
return make_tl_object<td_api::fileTypeSecure>();
case FileType::Background:
@ -105,8 +105,8 @@ FileType get_main_file_type(FileType file_type) {
switch (file_type) {
case FileType::Wallpaper:
return FileType::Background;
case FileType::SecureRaw:
return FileType::Secure;
case FileType::SecureDecrypted:
return FileType::SecureEncrypted;
case FileType::DocumentAsFile:
return FileType::Document;
case FileType::CallLog:
@ -146,9 +146,9 @@ CSlice get_file_type_name(FileType file_type) {
return CSlice("wallpapers");
case FileType::VideoNote:
return CSlice("video_notes");
case FileType::SecureRaw:
case FileType::SecureDecrypted:
return CSlice("passport");
case FileType::Secure:
case FileType::SecureEncrypted:
return CSlice("passport");
case FileType::Background:
return CSlice("wallpapers");
@ -186,8 +186,8 @@ FileTypeClass get_file_type_class(FileType file_type) {
case FileType::Ringtone:
case FileType::CallLog:
return FileTypeClass::Document;
case FileType::SecureRaw:
case FileType::Secure:
case FileType::SecureDecrypted:
case FileType::SecureEncrypted:
return FileTypeClass::Secure;
case FileType::Encrypted:
return FileTypeClass::Encrypted;
@ -218,8 +218,8 @@ FileDirType get_file_dir_type(FileType file_type) {
case FileType::Temp:
case FileType::Wallpaper:
case FileType::EncryptedThumbnail:
case FileType::Secure:
case FileType::SecureRaw:
case FileType::SecureEncrypted:
case FileType::SecureDecrypted:
case FileType::Background:
case FileType::Ringtone:
return FileDirType::Secure;

View File

@ -29,8 +29,8 @@ enum class FileType : int32 {
EncryptedThumbnail,
Wallpaper,
VideoNote,
SecureRaw,
Secure,
SecureDecrypted,
SecureEncrypted,
Background,
DocumentAsFile,
Ringtone,

View File

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