Improve names of FileType::Secure.
This commit is contained in:
parent
69eb286067
commit
641ee080c1
@ -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);
|
auto download_file_id = file_manager->dup_file_id(file_id);
|
||||||
file_id =
|
file_id =
|
||||||
file_manager
|
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())
|
PSTRING() << "#file_id#" << download_file_id.get(), DialogId(), file_view.size())
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
@ -354,8 +354,8 @@ EncryptedSecureFile get_encrypted_secure_file(FileManager *file_manager,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.file.file_id = file_manager->register_remote(
|
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");
|
FileLocationSource::FromServer, DialogId(), 0, secure_file->size_, PSTRING() << secure_file->id_ << ".jpg");
|
||||||
result.file.date = secure_file->date_;
|
result.file.date = secure_file->date_;
|
||||||
if (result.file.date < 0) {
|
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";
|
LOG(ERROR) << "Have wrong file in get_dated_file_object";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
dated_file.file_id =
|
dated_file.file_id = file_manager->register_remote(
|
||||||
file_manager->register_remote(FullRemoteFileLocation(FileType::SecureRaw, file_view.remote_location().get_id(),
|
FullRemoteFileLocation(FileType::SecureDecrypted, file_view.remote_location().get_id(),
|
||||||
file_view.remote_location().get_access_hash(),
|
file_view.remote_location().get_access_hash(), file_view.remote_location().get_dc_id(),
|
||||||
file_view.remote_location().get_dc_id(), ""),
|
""),
|
||||||
FileLocationSource::FromServer, DialogId(), file_view.size(),
|
FileLocationSource::FromServer, DialogId(), file_view.size(), file_view.expected_size(),
|
||||||
file_view.expected_size(), file_view.suggested_path());
|
file_view.suggested_path());
|
||||||
return get_dated_file_object(file_manager, dated_file);
|
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) {
|
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;
|
DatedFile result;
|
||||||
result.file_id = file_id;
|
result.file_id = file_id;
|
||||||
result.date = G()->unix_time();
|
result.date = G()->unix_time();
|
||||||
|
@ -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_);
|
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_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,
|
auto r_file_id = file_manager_->get_input_file_id(file_type, request.file_, DialogId(), false, is_secret,
|
||||||
!is_secure && !is_secret, is_secure);
|
!is_secure && !is_secret, is_secure);
|
||||||
if (r_file_id.is_error()) {
|
if (r_file_id.is_error()) {
|
||||||
|
@ -63,7 +63,7 @@ Result<FileLoader::FileInfo> FileDownloader::init() {
|
|||||||
if (encryption_key_.is_secure() && !encryption_key_.has_value_hash()) {
|
if (encryption_key_.is_secure() && !encryption_key_.has_value_hash()) {
|
||||||
LOG(ERROR) << "Can't download Secure file with unknown 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;
|
size_ = 0;
|
||||||
}
|
}
|
||||||
int32 part_size = 0;
|
int32 part_size = 0;
|
||||||
|
@ -361,13 +361,13 @@ class FullRemoteFileLocation {
|
|||||||
return file_type_ == FileType::Encrypted;
|
return file_type_ == FileType::Encrypted;
|
||||||
}
|
}
|
||||||
bool is_encrypted_secure() const {
|
bool is_encrypted_secure() const {
|
||||||
return file_type_ == FileType::Secure;
|
return file_type_ == FileType::SecureEncrypted;
|
||||||
}
|
}
|
||||||
bool is_encrypted_any() const {
|
bool is_encrypted_any() const {
|
||||||
return is_encrypted_secret() || is_encrypted_secure();
|
return is_encrypted_secret() || is_encrypted_secure();
|
||||||
}
|
}
|
||||||
bool is_secure() const {
|
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 {
|
bool is_document() const {
|
||||||
return is_common() && !is_secure() && !is_encrypted_secret();
|
return is_common() && !is_secure() && !is_encrypted_secret();
|
||||||
|
@ -923,8 +923,8 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
|
|||||||
case FileType::Encrypted:
|
case FileType::Encrypted:
|
||||||
case FileType::Temp:
|
case FileType::Temp:
|
||||||
case FileType::EncryptedThumbnail:
|
case FileType::EncryptedThumbnail:
|
||||||
case FileType::Secure:
|
case FileType::SecureEncrypted:
|
||||||
case FileType::SecureRaw:
|
case FileType::SecureDecrypted:
|
||||||
case FileType::DocumentAsFile:
|
case FileType::DocumentAsFile:
|
||||||
case FileType::CallLog:
|
case FileType::CallLog:
|
||||||
break;
|
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_;
|
<< ", generate_id = " << node->generate_id_ << ", generate_was_update = " << node->generate_was_update_;
|
||||||
return;
|
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
|
// 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";
|
LOG(INFO) << "Can't upload secure file " << node->main_file_id_ << " before it's size is known";
|
||||||
return;
|
return;
|
||||||
@ -2815,7 +2815,7 @@ void FileManager::run_upload(FileNodePtr node, std::vector<int> bad_parts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create encryption key if necessary
|
// 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()) {
|
file_view.encryption_key().empty()) {
|
||||||
CHECK(!node->file_ids_.empty());
|
CHECK(!node->file_ids_.empty());
|
||||||
bool success = set_encryption_key(node->file_ids_[0], FileEncryptionKey::create_secure_key());
|
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;
|
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> {
|
auto r_file_id = [&]() -> Result<FileId> {
|
||||||
switch (file->get_id()) {
|
switch (file->get_id()) {
|
||||||
|
@ -305,10 +305,10 @@ class FileView {
|
|||||||
return get_type() == FileType::Encrypted;
|
return get_type() == FileType::Encrypted;
|
||||||
}
|
}
|
||||||
bool is_encrypted_secure() const {
|
bool is_encrypted_secure() const {
|
||||||
return get_type() == FileType::Secure;
|
return get_type() == FileType::SecureEncrypted;
|
||||||
}
|
}
|
||||||
bool is_secure() const {
|
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 {
|
bool is_encrypted_any() const {
|
||||||
return is_encrypted_secret() || is_encrypted_secure();
|
return is_encrypted_secret() || is_encrypted_secure();
|
||||||
|
@ -39,7 +39,7 @@ FileType get_file_type(const td_api::FileType &file_type) {
|
|||||||
case td_api::fileTypeVideoNote::ID:
|
case td_api::fileTypeVideoNote::ID:
|
||||||
return FileType::VideoNote;
|
return FileType::VideoNote;
|
||||||
case td_api::fileTypeSecure::ID:
|
case td_api::fileTypeSecure::ID:
|
||||||
return FileType::Secure;
|
return FileType::SecureEncrypted;
|
||||||
case td_api::fileTypeNotificationSound::ID:
|
case td_api::fileTypeNotificationSound::ID:
|
||||||
return FileType::Ringtone;
|
return FileType::Ringtone;
|
||||||
case td_api::fileTypeNone::ID:
|
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>();
|
return make_tl_object<td_api::fileTypeWallpaper>();
|
||||||
case FileType::VideoNote:
|
case FileType::VideoNote:
|
||||||
return make_tl_object<td_api::fileTypeVideoNote>();
|
return make_tl_object<td_api::fileTypeVideoNote>();
|
||||||
case FileType::Secure:
|
case FileType::SecureEncrypted:
|
||||||
return make_tl_object<td_api::fileTypeSecure>();
|
return make_tl_object<td_api::fileTypeSecure>();
|
||||||
case FileType::SecureRaw:
|
case FileType::SecureDecrypted:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return make_tl_object<td_api::fileTypeSecure>();
|
return make_tl_object<td_api::fileTypeSecure>();
|
||||||
case FileType::Background:
|
case FileType::Background:
|
||||||
@ -105,8 +105,8 @@ FileType get_main_file_type(FileType file_type) {
|
|||||||
switch (file_type) {
|
switch (file_type) {
|
||||||
case FileType::Wallpaper:
|
case FileType::Wallpaper:
|
||||||
return FileType::Background;
|
return FileType::Background;
|
||||||
case FileType::SecureRaw:
|
case FileType::SecureDecrypted:
|
||||||
return FileType::Secure;
|
return FileType::SecureEncrypted;
|
||||||
case FileType::DocumentAsFile:
|
case FileType::DocumentAsFile:
|
||||||
return FileType::Document;
|
return FileType::Document;
|
||||||
case FileType::CallLog:
|
case FileType::CallLog:
|
||||||
@ -146,9 +146,9 @@ CSlice get_file_type_name(FileType file_type) {
|
|||||||
return CSlice("wallpapers");
|
return CSlice("wallpapers");
|
||||||
case FileType::VideoNote:
|
case FileType::VideoNote:
|
||||||
return CSlice("video_notes");
|
return CSlice("video_notes");
|
||||||
case FileType::SecureRaw:
|
case FileType::SecureDecrypted:
|
||||||
return CSlice("passport");
|
return CSlice("passport");
|
||||||
case FileType::Secure:
|
case FileType::SecureEncrypted:
|
||||||
return CSlice("passport");
|
return CSlice("passport");
|
||||||
case FileType::Background:
|
case FileType::Background:
|
||||||
return CSlice("wallpapers");
|
return CSlice("wallpapers");
|
||||||
@ -186,8 +186,8 @@ FileTypeClass get_file_type_class(FileType file_type) {
|
|||||||
case FileType::Ringtone:
|
case FileType::Ringtone:
|
||||||
case FileType::CallLog:
|
case FileType::CallLog:
|
||||||
return FileTypeClass::Document;
|
return FileTypeClass::Document;
|
||||||
case FileType::SecureRaw:
|
case FileType::SecureDecrypted:
|
||||||
case FileType::Secure:
|
case FileType::SecureEncrypted:
|
||||||
return FileTypeClass::Secure;
|
return FileTypeClass::Secure;
|
||||||
case FileType::Encrypted:
|
case FileType::Encrypted:
|
||||||
return FileTypeClass::Encrypted;
|
return FileTypeClass::Encrypted;
|
||||||
@ -218,8 +218,8 @@ FileDirType get_file_dir_type(FileType file_type) {
|
|||||||
case FileType::Temp:
|
case FileType::Temp:
|
||||||
case FileType::Wallpaper:
|
case FileType::Wallpaper:
|
||||||
case FileType::EncryptedThumbnail:
|
case FileType::EncryptedThumbnail:
|
||||||
case FileType::Secure:
|
case FileType::SecureEncrypted:
|
||||||
case FileType::SecureRaw:
|
case FileType::SecureDecrypted:
|
||||||
case FileType::Background:
|
case FileType::Background:
|
||||||
case FileType::Ringtone:
|
case FileType::Ringtone:
|
||||||
return FileDirType::Secure;
|
return FileDirType::Secure;
|
||||||
|
@ -29,8 +29,8 @@ enum class FileType : int32 {
|
|||||||
EncryptedThumbnail,
|
EncryptedThumbnail,
|
||||||
Wallpaper,
|
Wallpaper,
|
||||||
VideoNote,
|
VideoNote,
|
||||||
SecureRaw,
|
SecureDecrypted,
|
||||||
Secure,
|
SecureEncrypted,
|
||||||
Background,
|
Background,
|
||||||
DocumentAsFile,
|
DocumentAsFile,
|
||||||
Ringtone,
|
Ringtone,
|
||||||
|
@ -52,7 +52,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) && 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());
|
result->entries_.push_back(entry.get_network_statistics_entry_object());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user