Skip to content

Commit

Permalink
fixed mod reference tests not using installer options (#15500)
Browse files Browse the repository at this point in the history
* fixed mod reference tests not using installer options

There were quite a few mod reference tests that were using the basic
mod metadata without any installer options. This was causing collections
to pause.

hopefully finally fixes #15396

* cleanup
  • Loading branch information
IDCs authored and insomnious committed Apr 8, 2024
1 parent d49cfd0 commit 1d7e6fd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
74 changes: 37 additions & 37 deletions src/extensions/mod_management/InstallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ class InstallManager {
// adequate to show an error but not as a bug in Vortex
api.showErrorNotification('Failed to install dependencies',
err.message, { allowReport: false });
return [];
return Bluebird.resolve([]);
})
.catch(UserCanceled, () => {
log('info', 'canceled out of dependency install');
Expand All @@ -2339,15 +2339,15 @@ class InstallManager {
type: 'info',
message: 'Installation of dependencies canceled',
});
return [];
return Bluebird.resolve([]);
})
.catch(err => {
api.showErrorNotification('Failed to install dependencies', err);
return [];
return Bluebird.resolve([]);
})
.filter(dep => dep !== undefined);

return res;
return Bluebird.resolve(res);
}

private doInstallDependencies(api: IExtensionApi,
Expand Down Expand Up @@ -2423,27 +2423,28 @@ class InstallManager {
})));
};

const installDownload = (dep: IDependency, downloadId: string)
: Bluebird<string> => {
return Bluebird.resolve(this.mDependencyInstallsLimit.do(() => {
return abort.signal.aborted
? Bluebird.reject(new UserCanceled(false))
: this.withInstructions(api,
modName(sourceMod),
renderModReference(dep.reference),
dep.reference?.tag ?? downloadId,
dep.extra?.['instructions'],
recommended, () =>
this.installModAsync(dep.reference, api, downloadId,
{ choices: dep.installerChoices, patches: dep.patches }, dep.fileList,
gameId, silent))
.catch(err => {
if (err instanceof UserCanceled) {
err.skipped = true;
}
return Bluebird.reject(err);
});
}));
const installDownload = (dep: IDependency, downloadId: string) : Bluebird<string> => {
return new Bluebird<string>((resolve, reject) => {
return this.mDependencyInstallsLimit.do(async () => {
return abort.signal.aborted
? reject(new UserCanceled(false))
: this.withInstructions(api,
modName(sourceMod),
renderModReference(dep.reference),
dep.reference?.tag ?? downloadId,
dep.extra?.['instructions'],
recommended, () =>
this.installModAsync(dep.reference, api, downloadId,
{ choices: dep.installerChoices, patches: dep.patches }, dep.fileList,
gameId, silent)).then(res => resolve(res))
.catch(err => {
if (err instanceof UserCanceled) {
err.skipped = true;
}
return reject(err);
});
})
});
};

const doDownload = (dep: IDependency) => {
Expand Down Expand Up @@ -2528,20 +2529,18 @@ class InstallManager {
// being installed having a different tag than the rule
dep.reference = this.updateModRule(api, gameId, sourceModId, dep, {
...dep.reference,
fileList: dep.fileList,
patches: dep.patches,
installerChoices: dep.installerChoices,
tag: downloads[downloadId].modInfo.referenceTag,
}, recommended)?.reference;

// now at this point there may in fact already be a mod for the updated reference tag
if ((dep.mod === undefined) && (dep.reference !== undefined)) {
dep.mod = findModByRef(
dep.reference, api.getState().persistent.mods[gameId]);
log('info', 'updated mod', JSON.stringify(dep.mod));
}
dep.mod = findModByRef(dep.reference, api.getState().persistent.mods[gameId]);
} else {
log('info', 'downloaded as dependency', { downloadId });
}

let queryWrongMD5 = Bluebird.resolve();
let queryWrongMD5 = () => Bluebird.resolve();
if ((dep.mod === undefined)
&& (dep.reference?.versionMatch !== undefined)
&& !isFuzzyVersion(dep.reference.versionMatch)
Expand All @@ -2552,7 +2551,7 @@ class InstallManager {
expected: dep.lookupResults[0].value.fileMD5,
got: downloads[downloadId].fileMD5,
});
queryWrongMD5 = api.showDialog('question', 'Unrecognized file {{reference}}', {
queryWrongMD5 = () => api.showDialog('question', 'Unrecognized file {{reference}}', {
text: 'The file "{{fileName}}" that was just downloaded for dependency "{{reference}}" '
+ 'is not the exact file expected. This might not be an issue if the mod has been '
+ 'updated or repackaged by the author.\n'
Expand All @@ -2573,7 +2572,7 @@ class InstallManager {
}

return (dep.mod === undefined)
? queryWrongMD5
? queryWrongMD5()
.then(() => installDownload(dep, downloadId))
.catch(err => {
if (dep['reresolveDownloadHint'] === undefined) {
Expand Down Expand Up @@ -2629,7 +2628,7 @@ class InstallManager {
abort.abort();
};

return res;
return Bluebird.resolve(res);
}

private updateModRule(api: IExtensionApi, gameId: string, sourceModId: string,
Expand Down Expand Up @@ -2696,8 +2695,9 @@ class InstallManager {
if (dep['error'] !== undefined) {
prev.error.push(dep as IDependencyError);
} else {
const { mod } = dep as IDependency;
if ((mod === undefined) || !(modState[mod.id]?.enabled ?? false) || (!!mods[mod.id] && findModByRef(mod, mods) === undefined)) {
const { mod, reference } = dep as IDependency;
const modReference: IModReference = { ...(dep as IDependency), ...reference };
if ((mod === undefined) || !(modState[mod.id]?.enabled ?? false) || (!!mods[mod.id] && testModReference(mods[mod.id], modReference) !== true)) {
prev.success.push(dep as IDependency);
} else {
prev.existing.push(dep as IDependency);
Expand Down
8 changes: 7 additions & 1 deletion src/extensions/mod_management/util/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,13 @@ function gatherDependenciesGraph(
log('debug', 'no download found', { ref: JSON.stringify(rule.reference) });
}

const mod = findModByRef(rule.reference, state.persistent.mods[gameMode] ?? {});
const modReference: IModReference = {
...rule.reference,
fileList: rule.fileList,
patches: rule.extra?.patches ?? {},
installerChoices: rule.installerChoices,
}
const mod = findModByRef(modReference, state.persistent.mods[gameMode] ?? {});

let lookupResults: ILookupResult[];

Expand Down

0 comments on commit 1d7e6fd

Please sign in to comment.