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

Method handleLoaderUpdates

Telegram/SourceFiles/data/data_document.cpp:1305–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1303}
1304
1305void DocumentData::handleLoaderUpdates() {
1306 _loader->updates(
1307 ) | rpl::on_next_error_done([=] {
1308 _owner->documentLoadProgress(this);
1309 }, [=](FileLoader::Error error) {
1310 using FailureReason = FileLoader::FailureReason;
1311 if (error.started && _loader) {
1312 const auto origin = _loader->fileOrigin();
1313 const auto failedFileName = _loader->fileName();
1314 const auto retry = [=] {
1315 Ui::hideLayer();
1316 save(origin, failedFileName);
1317 };
1318 Ui::show(Ui::MakeConfirmBox({
1319 tr::lng_download_finish_failed(),
1320 crl::guard(&session(), retry)
1321 }));
1322 } else if (error.failureReason == FailureReason::FileWriteFailure) {
1323 if (!Core::App().settings().downloadPath().isEmpty()) {
1324 Core::App().settings().setDownloadPathBookmark(QByteArray());
1325 Core::App().settings().setDownloadPath(QString());
1326 Core::App().saveSettingsDelayed();
1327 InvokeQueued(qApp, [] {
1328 Ui::show(
1329 Ui::MakeInformBox(
1330 tr::lng_download_path_failed(tr::now)));
1331 });
1332 }
1333 }
1334 finishLoad();
1335 status = FileDownloadFailed;
1336 _owner->documentLoadFail(this, error.started);
1337 }, [=] {
1338 finishLoad();
1339 _owner->documentLoadDone(this);
1340 }, _loader->lifetime());
1341
1342}
1343
1344void DocumentData::cancel() {
1345 if (!loading()) {

Callers

nothing calls this directly

Calls 15

hideLayerFunction · 0.85
showFunction · 0.85
AppClass · 0.85
QByteArrayClass · 0.85
MakeInformBoxFunction · 0.85
fileNameMethod · 0.80
downloadPathMethod · 0.80
settingsMethod · 0.80
setDownloadPathMethod · 0.80
documentLoadFailMethod · 0.80
documentLoadDoneMethod · 0.80

Tested by

no test coverage detected