| 1286 | } |
| 1287 | |
| 1288 | void MainWindow::downloadUpdates(GoUpdate::Status status) |
| 1289 | { |
| 1290 | if(!APPLICATION->updatesAreAllowed()) |
| 1291 | { |
| 1292 | return; |
| 1293 | } |
| 1294 | qDebug() << "Downloading updates."; |
| 1295 | ProgressDialog updateDlg(this); |
| 1296 | status.rootPath = APPLICATION->root(); |
| 1297 | |
| 1298 | auto dlPath = FS::PathCombine(APPLICATION->root(), "update", "XXXXXX"); |
| 1299 | if (!FS::ensureFilePathExists(dlPath)) |
| 1300 | { |
| 1301 | CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show(); |
| 1302 | } |
| 1303 | GoUpdate::DownloadTask updateTask(APPLICATION->network(), status, dlPath, &updateDlg); |
| 1304 | // If the task succeeds, install the updates. |
| 1305 | if (updateDlg.execWithTask(&updateTask)) |
| 1306 | { |
| 1307 | /** |
| 1308 | * NOTE: This disables launching instances until the update either succeeds (and this process exits) |
| 1309 | * or the update fails (and the control leaves this scope). |
| 1310 | */ |
| 1311 | APPLICATION->updateIsRunning(true); |
| 1312 | UpdateController update(this, APPLICATION->root(), updateTask.updateFilesDir(), updateTask.operations()); |
| 1313 | update.installUpdates(); |
| 1314 | APPLICATION->updateIsRunning(false); |
| 1315 | } |
| 1316 | else |
| 1317 | { |
| 1318 | CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show(); |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | void MainWindow::onCatToggled(bool state) |
| 1323 | { |
nothing calls this directly
no test coverage detected