MCPcopy Create free account
hub / github.com/MultiMC/Launcher / downloadUpdates

Method downloadUpdates

launcher/ui/MainWindow.cpp:1288–1320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1286}
1287
1288void 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
1322void MainWindow::onCatToggled(bool state)
1323{

Callers

nothing calls this directly

Calls 11

PathCombineFunction · 0.85
ensureFilePathExistsFunction · 0.85
selectableFunction · 0.85
updatesAreAllowedMethod · 0.80
networkMethod · 0.80
execWithTaskMethod · 0.80
updateIsRunningMethod · 0.80
updateFilesDirMethod · 0.80
operationsMethod · 0.80
installUpdatesMethod · 0.80
failReasonMethod · 0.80

Tested by

no test coverage detected