Add source to PhotoSizeSource::get_unique.
This commit is contained in:
parent
a4c7d25c69
commit
0dc9aac724
@ -126,7 +126,7 @@ FileId register_photo_size(FileManager *file_manager, const PhotoSizeSource &sou
|
||||
PhotoFormat format) {
|
||||
LOG(DEBUG) << "Receive " << format << " photo " << id << " of type " << source.get_file_type("register_photo_size")
|
||||
<< " from " << dc_id;
|
||||
auto suggested_name = PSTRING() << source.get_unique_name(id) << '.' << format;
|
||||
auto suggested_name = PSTRING() << source.get_unique_name(id, "register_photo_size") << '.' << format;
|
||||
auto file_location_source = owner_dialog_id.get_type() == DialogType::SecretChat ? FileLocationSource::FromUser
|
||||
: FileLocationSource::FromServer;
|
||||
return file_manager->register_remote(
|
||||
|
@ -64,11 +64,11 @@ FileType PhotoSizeSource::get_file_type(const char *source) const {
|
||||
}
|
||||
}
|
||||
|
||||
string PhotoSizeSource::get_unique() const {
|
||||
string PhotoSizeSource::get_unique(const char *source) const {
|
||||
auto ptr = StackAllocator::alloc(16);
|
||||
MutableSlice data = ptr.as_slice();
|
||||
TlStorerUnsafe storer(data.ubegin());
|
||||
switch (get_type("get_unique")) {
|
||||
switch (get_type(source)) {
|
||||
case Type::Legacy:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -128,8 +128,8 @@ string PhotoSizeSource::get_unique() const {
|
||||
return string(data.begin(), size);
|
||||
}
|
||||
|
||||
string PhotoSizeSource::get_unique_name(int64 photo_id) const {
|
||||
switch (get_type("get_unique_name")) {
|
||||
string PhotoSizeSource::get_unique_name(int64 photo_id, const char *source) const {
|
||||
switch (get_type(source)) {
|
||||
case Type::Thumbnail:
|
||||
CHECK(0 <= thumbnail().thumbnail_type && thumbnail().thumbnail_type <= 127);
|
||||
return PSTRING() << photo_id << '_' << thumbnail().thumbnail_type;
|
||||
|
@ -242,10 +242,10 @@ struct PhotoSizeSource {
|
||||
}
|
||||
|
||||
// returns unique representation of the source
|
||||
string get_unique() const;
|
||||
string get_unique(const char *source) const;
|
||||
|
||||
// can't be called for Legacy sources
|
||||
string get_unique_name(int64 photo_id) const;
|
||||
string get_unique_name(int64 photo_id, const char *source) const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
@ -102,10 +102,12 @@ struct PhotoRemoteFileLocation {
|
||||
if (id_ != other.id_) {
|
||||
return id_ < other.id_;
|
||||
}
|
||||
return source_.get_unique() < other.source_.get_unique();
|
||||
return source_.get_unique("PhotoRemoteFileLocation::operator<") <
|
||||
other.source_.get_unique("PhotoRemoteFileLocation::operator<");
|
||||
}
|
||||
bool operator==(const PhotoRemoteFileLocation &other) const {
|
||||
return id_ == other.id_ && source_.get_unique() == other.source_.get_unique();
|
||||
return id_ == other.id_ && source_.get_unique("PhotoRemoteFileLocation::operator==") ==
|
||||
other.source_.get_unique("PhotoRemoteFileLocation::operator==");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -105,7 +105,7 @@ void PhotoRemoteFileLocation::parse(ParserT &parser) {
|
||||
template <class StorerT>
|
||||
void PhotoRemoteFileLocation::AsKey::store(StorerT &storer) const {
|
||||
using td::store;
|
||||
auto unique = key.source_.get_unique();
|
||||
auto unique = key.source_.get_unique("PhotoRemoteFileLocation::AsKey::store");
|
||||
switch (key.source_.get_type("PhotoRemoteFileLocation::AsKey::store")) {
|
||||
case PhotoSizeSource::Type::Legacy:
|
||||
case PhotoSizeSource::Type::StickerSetThumbnail:
|
||||
|
Loading…
Reference in New Issue
Block a user