MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / downloadUpdates

Method downloadUpdates

launcher/ui/MainWindow.cpp:1575–1607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1573}
1574
1575void MainWindow::downloadUpdates(GoUpdate::Status status)
1576{
1577 if(!APPLICATION->updatesAreAllowed())
1578 {
1579 return;
1580 }
1581 qDebug() << "Downloading updates.";
1582 ProgressDialog updateDlg(this);
1583 status.rootPath = APPLICATION->root();
1584
1585 auto dlPath = FS::PathCombine(APPLICATION->root(), "update", "XXXXXX");
1586 if (!FS::ensureFilePathExists(dlPath))
1587 {
1588 CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show();
1589 }
1590 GoUpdate::DownloadTask updateTask(APPLICATION->network(), status, dlPath, &updateDlg);
1591 // If the task succeeds, install the updates.
1592 if (updateDlg.execWithTask(&updateTask))
1593 {
1594 /**
1595 * NOTE: This disables launching instances until the update either succeeds (and this process exits)
1596 * or the update fails (and the control leaves this scope).
1597 */
1598 APPLICATION->updateIsRunning(true);
1599 UpdateController update(this, APPLICATION->root(), updateTask.updateFilesDir(), updateTask.operations());
1600 update.installUpdates();
1601 APPLICATION->updateIsRunning(false);
1602 }
1603 else
1604 {
1605 CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show();
1606 }
1607}
1608
1609void MainWindow::onCatToggled(bool state)
1610{

Callers

nothing calls this directly

Calls 12

PathCombineFunction · 0.85
ensureFilePathExistsFunction · 0.85
selectableFunction · 0.85
updatesAreAllowedMethod · 0.80
showMethod · 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