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

Method documentConvert

Telegram/SourceFiles/data/data_session.cpp:3780–3815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3778}
3779
3780void Session::documentConvert(
3781 not_null<DocumentData*> original,
3782 const MTPDocument &data) {
3783 const auto id = data.match([](const auto &data) {
3784 return data.vid().v;
3785 });
3786 const auto oldCacheKey = original->cacheKey();
3787 const auto oldGoodKey = original->goodThumbnailCacheKey();
3788 const auto idChanged = (original->id != id);
3789 if (idChanged) {
3790 auto i = _documents.find(id);
3791 if (i == _documents.end()) {
3792 const auto j = _documents.find(original->id);
3793 Assert(j != _documents.end());
3794 auto owned = std::move(j->second);
3795 _documents.erase(j);
3796 i = _documents.emplace(id, std::move(owned)).first;
3797 }
3798
3799 original->id = id;
3800 original->status = FileReady;
3801 original->uploadingData = nullptr;
3802
3803 if (i->second.get() != original) {
3804 documentApplyFields(i->second.get(), data);
3805 }
3806 }
3807 documentApplyFields(original, data);
3808 if (idChanged) {
3809 cache().moveIfEmpty(oldCacheKey, original->cacheKey());
3810 cache().moveIfEmpty(oldGoodKey, original->goodThumbnailCacheKey());
3811 if (stickers().savedGifs().indexOf(original) >= 0) {
3812 _session->local().writeSavedGifs();
3813 }
3814 }
3815}
3816
3817DocumentData *Session::documentFromWeb(
3818 const MTPWebDocument &data,

Callers 3

startMethod · 0.80
uploadForPeerMethod · 0.80
updateSentMediaMethod · 0.80

Calls 9

goodThumbnailCacheKeyMethod · 0.80
emplaceMethod · 0.80
writeSavedGifsMethod · 0.80
cacheKeyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
getMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected