Skip to content

Commit

Permalink
assistant_controller / Gracefully handle situation when one or two re…
Browse files Browse the repository at this point in the history
…positories fail to update (see #395)
  • Loading branch information
tobias-klein committed Nov 5, 2021
1 parent 6d19a94 commit c670fbc
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions app/frontend/components/module_assistant/assistant_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,39 @@ module.exports.updateRepositories = async function() {
if (updateInProgress) {
return;
}
updateInProgress = true;

preserveSelectedState();

updateInProgress = true;
preserveSelectedState();
await notifySubscribers('startUpdate');
const status = await ipcNsi.updateRepositoryConfig(process => notifySubscribers('progressUpdate', process));
if (status == 0) {

const MAX_FAILED_UPDATE_COUNT = 2;
var failedUpdateCount = 0;
const repoUpdateStatus = await ipcNsi.updateRepositoryConfig(process => notifySubscribers('progressUpdate', process));

for (var key in repoUpdateStatus) {
if (key != 'result' && repoUpdateStatus[key] == false) {
failedUpdateCount += 1;
console.warn("Repo update failed for " + key);
}
}

if (failedUpdateCount > 0) {
console.warn("Total failed updates: " + failedUpdateCount);
}

var overallStatus = 0;
if (failedUpdateCount > MAX_FAILED_UPDATE_COUNT) {
overallStatus = -1;
}

if (overallStatus == 0) {
restoreSelectedState();
const today = new Date();
state.reposUpdated = today;
await ipcSettings.set('lastSwordRepoUpdate', today);
}
await notifySubscribers('completedUpdate', status);

await notifySubscribers('completedUpdate', overallStatus);
updateInProgress = false;
};

Expand Down

0 comments on commit c670fbc

Please sign in to comment.