2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Check value size before putting to cache db.

This commit is contained in:
John Preston
2018-09-04 22:33:57 +03:00
parent 9ba331693f
commit 4b87363a20
7 changed files with 40 additions and 24 deletions

View File

@@ -971,11 +971,13 @@ bool mtpFileLoader::feedPart(int offset, bytes::const_span buffer) {
|| _locationType == UnknownFileLocation
|| _toCache == LoadToCacheAsWell) {
if (const auto key = cacheKey()) {
Auth().data().cache().put(
*key,
Storage::Cache::Database::TaggedValue(
base::duplicate(_data),
_cacheTag));
if (_data.size() <= Storage::kMaxFileInMemory) {
Auth().data().cache().put(
*key,
Storage::Cache::Database::TaggedValue(
base::duplicate(_data),
_cacheTag));
}
}
}
}
@@ -1197,11 +1199,13 @@ void webFileLoader::onFinished(const QByteArray &data) {
if (_localStatus == LocalStatus::NotFound) {
if (const auto key = cacheKey()) {
Auth().data().cache().put(
*key,
Storage::Cache::Database::TaggedValue(
base::duplicate(_data),
_cacheTag));
if (_data.size() <= Storage::kMaxFileInMemory) {
Auth().data().cache().put(
*key,
Storage::Cache::Database::TaggedValue(
base::duplicate(_data),
_cacheTag));
}
}
}
_downloader->taskFinished().notify();