From 03066d10c9f9813643167885fe6e1d5b71951525 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 23 Dec 2019 04:32:02 +0300 Subject: [PATCH] Do not store photo.id in file_unique_id. GitOrigin-RevId: 51a888c863b90f220964444255c46c9ac5e91c2e --- td/telegram/files/FileLocation.h | 9 +++++---- td/telegram/files/FileLocation.hpp | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index dd254319..919dd20f 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -92,12 +92,13 @@ struct PhotoRemoteFileLocation { struct AsKey { const PhotoRemoteFileLocation &key; + bool is_unique; template void store(StorerT &storer) const; }; - AsKey as_key() const { - return AsKey{*this}; + AsKey as_key(bool is_unique) const { + return AsKey{*this, is_unique}; } bool operator<(const PhotoRemoteFileLocation &other) const { @@ -128,7 +129,7 @@ struct WebRemoteFileLocation { template void store(StorerT &storer) const; }; - AsKey as_key() const { + AsKey as_key(bool /*is_unique*/) const { return AsKey{*this}; } @@ -159,7 +160,7 @@ struct CommonRemoteFileLocation { template void store(StorerT &storer) const; }; - AsKey as_key() const { + AsKey as_key(bool /*is_unique*/) const { return AsKey{*this}; } diff --git a/td/telegram/files/FileLocation.hpp b/td/telegram/files/FileLocation.hpp index a762ba48..252df2d1 100644 --- a/td/telegram/files/FileLocation.hpp +++ b/td/telegram/files/FileLocation.hpp @@ -68,7 +68,9 @@ void PhotoRemoteFileLocation::parse(ParserT &parser) { template void PhotoRemoteFileLocation::AsKey::store(StorerT &storer) const { using td::store; - store(key.id_, storer); + if (!is_unique) { + store(key.id_, storer); + } store(key.volume_id_, storer); store(key.local_id_, storer); } @@ -207,7 +209,7 @@ void FullRemoteFileLocation::AsKey::store(StorerT &storer) const { store(key.key_type(), storer); key.variant_.visit([&](auto &&value) { using td::store; - store(value.as_key(), storer); + store(value.as_key(false), storer); }); } @@ -252,7 +254,7 @@ void FullRemoteFileLocation::AsUnique::store(StorerT &storer) const { store(type, storer); key.variant_.visit([&](auto &&value) { using td::store; - store(value.as_key(), storer); + store(value.as_key(true), storer); }); }