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

Function LoadCloudFile

Telegram/SourceFiles/data/data_cloud_file.cpp:233–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void LoadCloudFile(
234 not_null<Main::Session*> session,
235 CloudFile &file,
236 FileOrigin origin,
237 LoadFromCloudSetting fromCloud,
238 bool autoLoading,
239 uint8 cacheTag,
240 Fn<bool()> finalCheck,
241 Fn<void(CloudFile&)> done,
242 Fn<void(bool)> fail,
243 Fn<void()> progress,
244 int downloadFrontPartSize = 0) {
245 const auto loadSize = downloadFrontPartSize
246 ? std::min(downloadFrontPartSize, file.byteSize)
247 : file.byteSize;
248 if (file.loader) {
249 if (fromCloud == LoadFromCloudOrLocal) {
250 file.loader->permitLoadFromCloud();
251 }
252 if (file.loader->loadSize() < loadSize) {
253 file.loader->increaseLoadSize(loadSize, autoLoading);
254 }
255 return;
256 } else if ((file.flags & CloudFile::Flag::Failed)
257 || !file.location.valid()
258 || (finalCheck && !finalCheck())) {
259 return;
260 }
261 file.flags &= ~CloudFile::Flag::Cancelled;
262 file.loader = CreateFileLoader(
263 session,
264 file.location.file(),
265 origin,
266 QString(),
267 loadSize,
268 file.byteSize,
269 UnknownFileLocation,
270 LoadToCacheAsWell,
271 fromCloud,
272 autoLoading,
273 cacheTag);
274
275 const auto finish = [done](CloudFile &file) {
276 if (!file.loader || file.loader->cancelled()) {
277 file.flags |= CloudFile::Flag::Cancelled;
278 } else {
279 file.flags |= CloudFile::Flag::Loaded;
280 done(file);
281 }
282 // NB! file.loader may be in ~FileLoader() already.
283 if (const auto loader = base::take(file.loader)) {
284 if ((file.flags & CloudFile::Flag::Cancelled)
285 && !loader->cancelled()) {
286 loader->cancel();
287 }
288 }
289 };
290

Callers 6

loadMethod · 0.85
loadThumbnailMethod · 0.85
loadVideoThumbnailMethod · 0.85
loadMethod · 0.85
loadVideoMethod · 0.85
loadThumbnailMethod · 0.85

Calls 15

CreateFileLoaderFunction · 0.85
permitLoadFromCloudMethod · 0.80
loadSizeMethod · 0.80
increaseLoadSizeMethod · 0.80
imageDataMethod · 0.80
bytesMethod · 0.80
QStringClass · 0.50
finishFunction · 0.50
validMethod · 0.45
cancelledMethod · 0.45
cancelMethod · 0.45
updatesMethod · 0.45

Tested by

no test coverage detected