diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index 7a9456b7..63d58425 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -845,18 +845,15 @@ class RemoteFileLocation { void parse(ParserT &parser) { auto type = static_cast(parser.fetch_int()); switch (type) { - case Type::Empty: { + case Type::Empty: variant_ = EmptyRemoteFileLocation(); return; - } - case Type::Partial: { + case Type::Partial: variant_ = PartialRemoteFileLocation(); return partial().parse(parser); - } - case Type::Full: { + case Type::Full: variant_ = FullRemoteFileLocation(); return full().parse(parser); - } } parser.set_error("Invalid type in RemoteFileLocation"); } @@ -879,9 +876,26 @@ class RemoteFileLocation { Variant variant_; friend bool operator==(const RemoteFileLocation &lhs, const RemoteFileLocation &rhs); + + bool is_empty() const { + switch (type()) { + case Type::Empty: + return true; + case Type::Partial: + return partial().ready_part_count_ == 0; + case Type::Full: + return false; + default: + UNREACHABLE(); + return false; + } + } }; inline bool operator==(const RemoteFileLocation &lhs, const RemoteFileLocation &rhs) { + if (lhs.is_empty() && rhs.is_empty()) { + return true; + } return lhs.variant_ == rhs.variant_; }