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

Set correct cache tags for different file types.

This commit is contained in:
John Preston
2018-08-29 00:09:55 +03:00
parent e2f08d4161
commit 55f60866cb
9 changed files with 119 additions and 31 deletions

View File

@@ -771,13 +771,15 @@ void DocumentData::save(
&_urlLocation,
size,
fromCloud,
autoLoading);
autoLoading,
cacheTag());
} else if (!_access && !_url.isEmpty()) {
_loader = new webFileLoader(
_url,
toFile,
fromCloud,
autoLoading);
autoLoading,
cacheTag());
} else {
_loader = new mtpFileLoader(
_dc,
@@ -790,7 +792,8 @@ void DocumentData::save(
size,
(saveToCache() ? LoadToCacheAsWell : LoadToFileOnly),
fromCloud,
autoLoading);
autoLoading,
cacheTag());
}
_loader->connect(_loader, SIGNAL(progress(FileLoader*)), App::main(), SLOT(documentLoadProgress(FileLoader*)));
@@ -1098,6 +1101,19 @@ Storage::Cache::Key DocumentData::cacheKey() const {
}
}
uint8 DocumentData::cacheTag() const {
if (type == StickerDocument) {
return Data::kStickerCacheTag;
} else if (isVoiceMessage()) {
return Data::kVoiceMessageCacheTag;
} else if (isVideoMessage()) {
return Data::kVideoMessageCacheTag;
} else if (isAnimation()) {
return Data::kAnimationCacheTag;
}
return 0;
}
QString DocumentData::composeNameString() const {
if (auto songData = song()) {
return ComposeNameString(

View File

@@ -180,6 +180,7 @@ public:
MediaKey mediaKey() const;
Storage::Cache::Key cacheKey() const;
uint8 cacheTag() const;
static QString ComposeNameString(
const QString &filename,

View File

@@ -357,7 +357,9 @@ bool MediaPhoto::updateSentMedia(const MTPMessageMedia &media) {
}
Auth().data().cache().putIfEmpty(
Data::StorageCacheKey(key),
image->savedData());
Storage::Cache::Database::TaggedValue(
image->savedData(),
Data::kImageCacheTag));
};
auto &sizes = photo.c_photo().vsizes.v;
auto max = 0;

View File

@@ -41,6 +41,12 @@ Storage::Cache::Key StorageCacheKey(const StorageImageLocation &location);
Storage::Cache::Key WebDocumentCacheKey(const WebFileLocation &location);
Storage::Cache::Key UrlCacheKey(const QString &location);
constexpr auto kImageCacheTag = uint8(0x01);
constexpr auto kStickerCacheTag = uint8(0x02);
constexpr auto kVoiceMessageCacheTag = uint8(0x03);
constexpr auto kVideoMessageCacheTag = uint8(0x04);
constexpr auto kAnimationCacheTag = uint8(0x05);
} // namespace Data
struct MessageGroupId {