From d9f51ffb7702713ab20e81907f4b2f7c0cd113e9 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Sun, 20 Jan 2019 18:26:51 +0300 Subject: [PATCH] FileManager: bugfixes GitOrigin-RevId: c8b289a23ea898fa1772d0184b66b813dcbfe760 --- td/telegram/files/FileLocation.h | 15 +++++++++++---- td/telegram/files/FileManager.cpp | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index 16410692..0a2101cb 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -279,6 +279,13 @@ class FullRemoteFileLocation { friend StringBuilder &operator<<(StringBuilder &string_builder, const FullRemoteFileLocation &full_remote_file_location); + int32 key_type() const { + auto type = static_cast(file_type_); + if (is_web()) { + type |= WEB_LOCATION_FLAG; + } + return type; + } int32 full_type() const { auto type = static_cast(file_type_); if (is_web()) { @@ -350,7 +357,7 @@ class FullRemoteFileLocation { template void store(StorerT &storer) const { using td::store; - store(key.full_type(), storer); + store(key.key_type(), storer); key.variant_.visit([&](auto &&value) { using td::store; store(value.as_key(), storer); @@ -521,8 +528,8 @@ class FullRemoteFileLocation { } bool operator<(const FullRemoteFileLocation &other) const { - if (full_type() != other.full_type()) { - return full_type() < other.full_type(); + if (key_type() != other.key_type()) { + return key_type() < other.key_type(); } if (dc_id_ != other.dc_id_) { return dc_id_ < other.dc_id_; @@ -541,7 +548,7 @@ class FullRemoteFileLocation { } } bool operator==(const FullRemoteFileLocation &other) const { - if (full_type() != other.full_type()) { + if (key_type() != other.key_type()) { return false; } if (dc_id_ != other.dc_id_) { diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 902848ce..66d07b4f 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -146,7 +146,8 @@ void FileNode::set_remote_location(const RemoteFileLocation &remote, FileLocatio } if (remote_ == remote) { if (remote_.type() == RemoteFileLocation::Type::Full) { - if (remote_.full().get_access_hash() == remote.full().get_access_hash()) { + if (remote_.full().get_access_hash() == remote.full().get_access_hash() && + remote_.full().has_file_reference() == remote.full().has_file_reference()) { return; } } else {