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

Method downloadUpdates

launcher/ui/MainWindow.cpp:1270–1302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1268}
1269
1270void MainWindow::downloadUpdates(GoUpdate::Status status)
1271{
1272 if(!APPLICATION->updatesAreAllowed())
1273 {
1274 return;
1275 }
1276 qDebug() << "Downloading updates.";
1277 ProgressDialog updateDlg(this);
1278 status.rootPath = APPLICATION->root();
1279
1280 auto dlPath = FS::PathCombine(APPLICATION->root(), "update", "XXXXXX");
1281 if (!FS::ensureFilePathExists(dlPath))
1282 {
1283 CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show();
1284 }
1285 GoUpdate::DownloadTask updateTask(APPLICATION->network(), status, dlPath, &updateDlg);
1286 // If the task succeeds, install the updates.
1287 if (updateDlg.execWithTask(&updateTask))
1288 {
1289 /**
1290 * NOTE: This disables launching instances until the update either succeeds (and this process exits)
1291 * or the update fails (and the control leaves this scope).
1292 */
1293 APPLICATION->updateIsRunning(true);
1294 UpdateController update(this, APPLICATION->root(), updateTask.updateFilesDir(), updateTask.operations());
1295 update.installUpdates();
1296 APPLICATION->updateIsRunning(false);
1297 }
1298 else
1299 {
1300 CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show();
1301 }
1302}
1303
1304void MainWindow::onCatToggled(bool state)
1305{

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