| 1303 | } |
| 1304 | |
| 1305 | void 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 | |
| 1344 | void DocumentData::cancel() { |
| 1345 | if (!loading()) { |
nothing calls this directly
no test coverage detected