2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Use empty Storage::Cache::Key as nullopt.

This commit is contained in:
John Preston
2020-05-20 16:28:18 +04:00
parent 581a21dbd9
commit fb322b5fc5
20 changed files with 71 additions and 68 deletions

View File

@@ -627,7 +627,11 @@ void DocumentData::updateThumbnails(
loadThumbnail(origin);
}
if (!thumbnail.bytes.isEmpty()) {
// #TODO optimize put to cache
owner().cache().putIfEmpty(
_thumbnailLocation.file().cacheKey(),
Storage::Cache::Database::TaggedValue(
base::duplicate(thumbnail.bytes),
Data::kImageCacheTag));
}
}
}
@@ -761,19 +765,17 @@ PhotoData *DocumentData::goodThumbnailPhoto() const {
return _goodThumbnailPhoto;
}
auto DocumentData::bigFileBaseCacheKey() const
-> std::optional<Storage::Cache::Key> {
if (hasRemoteLocation()) {
return StorageFileLocation(
Storage::Cache::Key DocumentData::bigFileBaseCacheKey() const {
return hasRemoteLocation()
? StorageFileLocation(
_dc,
session().userId(),
MTP_inputDocumentFileLocation(
MTP_long(id),
MTP_long(_access),
MTP_bytes(_fileReference),
MTP_string())).bigFileBaseCacheKey();
}
return std::nullopt;
MTP_string())).bigFileBaseCacheKey()
: Storage::Cache::Key();
}
bool DocumentData::saveToCache() const {
@@ -786,12 +788,6 @@ bool DocumentData::saveToCache() const {
}
void DocumentData::unload() {
// Forget thumb only when image cache limit exceeds.
//
// Also, you can't unload() images that you don't own
// from the destructor, because they're already destroyed.
//
//_thumbnail->unload();
_replyPreview = nullptr;
}
@@ -1333,14 +1329,6 @@ void DocumentData::refreshFileReference(const QByteArray &value) {
_thumbnailLocation.refreshFileReference(value);
}
void DocumentData::refreshStickerThumbFileReference() {
// #TODO optimize
//if (_thumbnailLoader) {
// _thumbnailLocation.refreshFileReference(
// _thumbnailLoader->fileReference());
//}
}
QString DocumentData::filename() const {
return _filename;
}