MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / writeStickerSets

Method writeStickerSets

Telegram/SourceFiles/storage/storage_account.cpp:1941–2041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1939// CheckSet is a functor on Data::StickersSet, which returns a StickerSetCheckResult.
1940template <typename CheckSet>
1941void Account::writeStickerSets(
1942 FileKey &stickersKey,
1943 CheckSet checkSet,
1944 const Data::StickersSetsOrder &order) {
1945 using SetFlag = Data::StickersSetFlag;
1946
1947 const auto &sets = _owner->session().data().stickers().sets();
1948 if (sets.empty()) {
1949 if (stickersKey) {
1950 ClearKey(stickersKey, _basePath);
1951 stickersKey = 0;
1952 writeMapDelayed();
1953 }
1954 return;
1955 }
1956
1957 // versionTag + version + count
1958 quint32 size = sizeof(quint32) + sizeof(qint32) + sizeof(qint32);
1959
1960 int32 setsCount = 0;
1961 for (const auto &[id, set] : sets) {
1962 const auto raw = set.get();
1963 auto result = checkSet(*raw);
1964 if (result == StickerSetCheckResult::Abort) {
1965 return;
1966 } else if (result == StickerSetCheckResult::Skip) {
1967 continue;
1968 }
1969
1970 // id
1971 // + accessHash
1972 // + hash
1973 // + title
1974 // + shortName
1975 // + stickersCount
1976 // + flags
1977 // + installDate
1978 // + thumbnailDocumentId
1979 // + thumbnailType
1980 // + thumbnailLocation
1981 size += sizeof(quint64) * 3
1982 + Serialize::stringSize(raw->title)
1983 + Serialize::stringSize(raw->shortName)
1984 + sizeof(qint32) * 3
1985 + sizeof(quint64)
1986 + sizeof(qint32)
1987 + Serialize::imageLocationSize(raw->thumbnailLocation());
1988 if (raw->flags & SetFlag::NotLoaded) {
1989 continue;
1990 }
1991
1992 for (const auto sticker : std::as_const(raw->stickers)) {
1993 size += Serialize::Document::sizeInStream(sticker);
1994 }
1995
1996 size += sizeof(qint32); // datesCount
1997 if (!raw->dates.empty()) {
1998 Assert(raw->stickers.size() == raw->dates.size());

Callers

nothing calls this directly

Calls 15

ClearKeyFunction · 0.85
stringSizeFunction · 0.85
imageLocationSizeFunction · 0.85
GenerateKeyFunction · 0.85
writeEncryptedMethod · 0.80
stickersMethod · 0.45
dataMethod · 0.45
sessionMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
cbeginMethod · 0.45

Tested by

no test coverage detected