Add td_api::remoteFile.unique_id.
GitOrigin-RevId: b6355e905d7268aefbb4dd2e951b15e12504ee54
This commit is contained in:
parent
d5ba35e2f0
commit
edd3bb94a4
@ -138,12 +138,14 @@ temporaryPasswordState has_password:Bool valid_for:int32 = TemporaryPasswordStat
|
|||||||
localFile path:string can_be_downloaded:Bool can_be_deleted:Bool is_downloading_active:Bool is_downloading_completed:Bool download_offset:int32 downloaded_prefix_size:int32 downloaded_size:int32 = LocalFile;
|
localFile path:string can_be_downloaded:Bool can_be_deleted:Bool is_downloading_active:Bool is_downloading_completed:Bool download_offset:int32 downloaded_prefix_size:int32 downloaded_size:int32 = LocalFile;
|
||||||
|
|
||||||
//@description Represents a remote file
|
//@description Represents a remote file
|
||||||
//@id Remote file identifier; may be empty. Can be used across application restarts or even from other devices for the current user. If the ID starts with "http://" or "https://", it represents the HTTP URL of the file. TDLib is currently unable to download files if only their URL is known.
|
//@id Remote file identifier; may be empty. Can be used across application restarts or even from other devices for the current user. Uniquely identifies a file, but a file can have a lot of different valid identifiers.
|
||||||
|
//-If the ID starts with "http://" or "https://", it represents the HTTP URL of the file. TDLib is currently unable to download files if only their URL is known.
|
||||||
//-If downloadFile is called on such a file or if it is sent to a secret chat, TDLib starts a file generation process by sending updateFileGenerationStart to the client with the HTTP URL in the original_path and "#url#" as the conversion string. Clients should generate the file by downloading it to the specified location
|
//-If downloadFile is called on such a file or if it is sent to a secret chat, TDLib starts a file generation process by sending updateFileGenerationStart to the client with the HTTP URL in the original_path and "#url#" as the conversion string. Clients should generate the file by downloading it to the specified location
|
||||||
|
//@unique_id Unique file identifier; may be empty if unknown. The unique file identifier which is the same for the same file even for different users and is persistent over time
|
||||||
//@is_uploading_active True, if the file is currently being uploaded (or a remote copy is being generated by some other means)
|
//@is_uploading_active True, if the file is currently being uploaded (or a remote copy is being generated by some other means)
|
||||||
//@is_uploading_completed True, if a remote copy is fully available
|
//@is_uploading_completed True, if a remote copy is fully available
|
||||||
//@uploaded_size Size of the remote available part of the file; 0 if unknown
|
//@uploaded_size Size of the remote available part of the file; 0 if unknown
|
||||||
remoteFile id:string is_uploading_active:Bool is_uploading_completed:Bool uploaded_size:int32 = RemoteFile;
|
remoteFile id:string unique_id:string is_uploading_active:Bool is_uploading_completed:Bool uploaded_size:int32 = RemoteFile;
|
||||||
|
|
||||||
//@description Represents a file
|
//@description Represents a file
|
||||||
//@id Unique file identifier
|
//@id Unique file identifier
|
||||||
|
Binary file not shown.
@ -837,8 +837,8 @@ td_api::object_ptr<td_api::localFile> copy(const td_api::localFile &obj) {
|
|||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
td_api::object_ptr<td_api::remoteFile> copy(const td_api::remoteFile &obj) {
|
td_api::object_ptr<td_api::remoteFile> copy(const td_api::remoteFile &obj) {
|
||||||
return td_api::make_object<td_api::remoteFile>(obj.id_, obj.is_uploading_active_, obj.is_uploading_completed_,
|
return td_api::make_object<td_api::remoteFile>(obj.id_, obj.unique_id_, obj.is_uploading_active_,
|
||||||
obj.uploaded_size_);
|
obj.is_uploading_completed_, obj.uploaded_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -284,6 +284,16 @@ class FullRemoteFileLocation {
|
|||||||
return AsKey{*this};
|
return AsKey{*this};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct AsUnique {
|
||||||
|
const FullRemoteFileLocation &key;
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void store(StorerT &storer) const;
|
||||||
|
};
|
||||||
|
AsUnique as_unique() const {
|
||||||
|
return AsUnique{*this};
|
||||||
|
}
|
||||||
|
|
||||||
DcId get_dc_id() const {
|
DcId get_dc_id() const {
|
||||||
CHECK(!is_web());
|
CHECK(!is_web());
|
||||||
return dc_id_;
|
return dc_id_;
|
||||||
|
@ -202,6 +202,17 @@ void FullRemoteFileLocation::AsKey::store(StorerT &storer) const {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class StorerT>
|
||||||
|
void FullRemoteFileLocation::AsUnique::store(StorerT &storer) const {
|
||||||
|
using td::store;
|
||||||
|
|
||||||
|
store(key.location_type(), storer);
|
||||||
|
key.variant_.visit([&](auto &&value) {
|
||||||
|
using td::store;
|
||||||
|
store(value.as_key(), storer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void RemoteFileLocation::store(StorerT &storer) const {
|
void RemoteFileLocation::store(StorerT &storer) const {
|
||||||
td::store(variant_, storer);
|
td::store(variant_, storer);
|
||||||
|
@ -2665,6 +2665,14 @@ static bool is_background_type(FileType type) {
|
|||||||
return type == FileType::Wallpaper || type == FileType::Background;
|
return type == FileType::Wallpaper || type == FileType::Background;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string FileManager::get_unique_id(const FullGenerateFileLocation &location) {
|
||||||
|
return base64url_encode(zero_encode('\xff' + serialize(location)));
|
||||||
|
}
|
||||||
|
|
||||||
|
string FileManager::get_unique_id(const FullRemoteFileLocation &location) {
|
||||||
|
return base64url_encode(zero_encode(serialize(location.as_unique())));
|
||||||
|
}
|
||||||
|
|
||||||
string FileManager::get_persistent_id(const FullGenerateFileLocation &location) {
|
string FileManager::get_persistent_id(const FullGenerateFileLocation &location) {
|
||||||
auto binary = serialize(location);
|
auto binary = serialize(location);
|
||||||
|
|
||||||
@ -2672,6 +2680,7 @@ string FileManager::get_persistent_id(const FullGenerateFileLocation &location)
|
|||||||
binary.push_back(PERSISTENT_ID_VERSION_MAP);
|
binary.push_back(PERSISTENT_ID_VERSION_MAP);
|
||||||
return base64url_encode(binary);
|
return base64url_encode(binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
string FileManager::get_persistent_id(const FullRemoteFileLocation &location) {
|
string FileManager::get_persistent_id(const FullRemoteFileLocation &location) {
|
||||||
auto location_copy = location;
|
auto location_copy = location;
|
||||||
location_copy.clear_file_reference();
|
location_copy.clear_file_reference();
|
||||||
@ -2805,12 +2814,17 @@ td_api::object_ptr<td_api::file> FileManager::get_file_object(FileId file_id, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
string persistent_file_id;
|
string persistent_file_id;
|
||||||
|
string unique_file_id;
|
||||||
if (file_view.has_alive_remote_location()) {
|
if (file_view.has_alive_remote_location()) {
|
||||||
persistent_file_id = get_persistent_id(file_view.remote_location());
|
persistent_file_id = get_persistent_id(file_view.remote_location());
|
||||||
|
if (!file_view.remote_location().is_web()) {
|
||||||
|
unique_file_id = get_unique_id(file_view.remote_location());
|
||||||
|
}
|
||||||
} else if (file_view.has_url()) {
|
} else if (file_view.has_url()) {
|
||||||
persistent_file_id = file_view.url();
|
persistent_file_id = file_view.url();
|
||||||
} else if (file_view.has_generate_location() && begins_with(file_view.generate_location().conversion_, "#map#")) {
|
} else if (file_view.has_generate_location() && begins_with(file_view.generate_location().conversion_, "#map#")) {
|
||||||
persistent_file_id = get_persistent_id(file_view.generate_location());
|
persistent_file_id = get_persistent_id(file_view.generate_location());
|
||||||
|
unique_file_id = get_unique_id(file_view.generate_location());
|
||||||
}
|
}
|
||||||
bool is_uploading_completed = !persistent_file_id.empty();
|
bool is_uploading_completed = !persistent_file_id.empty();
|
||||||
|
|
||||||
@ -2841,8 +2855,8 @@ td_api::object_ptr<td_api::file> FileManager::get_file_object(FileId file_id, bo
|
|||||||
td_api::make_object<td_api::localFile>(std::move(path), can_be_downloaded, can_be_deleted,
|
td_api::make_object<td_api::localFile>(std::move(path), can_be_downloaded, can_be_deleted,
|
||||||
file_view.is_downloading(), file_view.has_local_location(),
|
file_view.is_downloading(), file_view.has_local_location(),
|
||||||
download_offset, local_prefix_size, local_total_size),
|
download_offset, local_prefix_size, local_total_size),
|
||||||
td_api::make_object<td_api::remoteFile>(std::move(persistent_file_id), file_view.is_uploading(),
|
td_api::make_object<td_api::remoteFile>(std::move(persistent_file_id), std::move(unique_file_id),
|
||||||
is_uploading_completed, remote_size));
|
file_view.is_uploading(), is_uploading_completed, remote_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int32> FileManager::get_file_ids_object(const vector<FileId> &file_ids, bool with_main_file_id) {
|
vector<int32> FileManager::get_file_ids_object(const vector<FileId> &file_ids, bool with_main_file_id) {
|
||||||
|
@ -579,6 +579,9 @@ class FileManager : public FileLoadManager::Callback {
|
|||||||
void flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate, const char *source);
|
void flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate, const char *source);
|
||||||
void load_from_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate);
|
void load_from_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate);
|
||||||
|
|
||||||
|
string get_unique_id(const FullGenerateFileLocation &location);
|
||||||
|
string get_unique_id(const FullRemoteFileLocation &location);
|
||||||
|
|
||||||
string get_persistent_id(const FullGenerateFileLocation &location);
|
string get_persistent_id(const FullGenerateFileLocation &location);
|
||||||
string get_persistent_id(const FullRemoteFileLocation &location);
|
string get_persistent_id(const FullRemoteFileLocation &location);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user