Skip to content

Commit

Permalink
modtype, installer and filelist now checked on collection install (#1…
Browse files Browse the repository at this point in the history
…5279)

* mod reference data checks now include installer choices

* now comparing patches and fileEntries/hashes when installing collection

* using the collections submodule for #347 fix

---------

Co-authored-by: IDCs <[email protected]>
  • Loading branch information
insomnious and IDCs authored Feb 28, 2024
1 parent 1ac50b3 commit fafff95
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
15 changes: 13 additions & 2 deletions src/extensions/mod_management/InstallManager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import { addLocalDownload, removeDownload, setDownloadHashByFile,
setDownloadModInfo,
startActivity, stopActivity } from '../../actions';
Expand Down Expand Up @@ -2090,6 +2091,14 @@ class InstallManager {
attributes['version'] = extra.version;
}

if (extra.patches !== undefined) {
attributes['patches'] = extra.patches;
}

if (extra.fileList !== undefined) {
attributes['fileList'] = extra.fileList;
}

api.store.dispatch(setModAttributes(gameId, modId, attributes));
}

Expand Down Expand Up @@ -2407,7 +2416,7 @@ class InstallManager {
dep.extra?.['instructions'],
recommended, () =>
this.installModAsync(dep.reference, api, downloadId,
{ choices: dep.installerChoices }, dep.fileList,
{ choices: dep.installerChoices, patches: dep.patches }, dep.fileList,
gameId, silent))
.catch(err => {
if (err instanceof UserCanceled) {
Expand Down Expand Up @@ -2631,7 +2640,9 @@ class InstallManager {
dependencies.forEach(dep => {
const updatedRef: IModReference = { ...dep.reference };
updatedRef.idHint = dep.mod?.id;

updatedRef.installerChoices = dep.installerChoices;
updatedRef.patches = dep.patches;
updatedRef.fileList = dep.fileList;
this.updateModRule(api, gameId, sourceModId, dep, updatedRef, recommended);
});
return Bluebird.resolve();
Expand Down
1 change: 1 addition & 0 deletions src/extensions/mod_management/types/IDependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface IDependency {
lookupResults: ILookupResultEx[];
fileList?: IFileListItem[];
installerChoices?: any;
patches?: any;
mod?: IMod;
extra?: { [key: string]: any };
phase?: number;
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/mod_management/types/IMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export interface IModReference extends IReference {
// the user chose for the mod.
description?: string;
instructions?: string;
installerChoices?: any;
fileList?: IFileListItem[];
patches?: any;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/extensions/mod_management/util/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export function findModByRef(reference: IModReference, mods: { [modId: string]:
delete reference.fileMD5;
}

if (reference['md5Hint'] !== undefined) {
if (reference['md5Hint'] !== undefined
&& reference.installerChoices === undefined
&& reference.patches === undefined
&& reference.fileList === undefined) {
const result = Object.keys(mods)
.find(dlId => mods[dlId].attributes?.fileMD5 === reference['md5Hint']);
if (result !== undefined) {
Expand Down Expand Up @@ -298,6 +301,7 @@ interface IDependencyNode extends IDependency {
redundant: boolean;
fileList?: IFileListItem[];
installerChoices?: any;
patches?: any;
reresolveDownloadHint?: () => void;
}

Expand Down Expand Up @@ -352,6 +356,7 @@ function gatherDependenciesGraph(
dependencies: nodes.filter(node => node !== null),
redundant: false,
extra: rule.extra,
patches: rule.extra?.patches ?? {},
installerChoices: rule.installerChoices,
fileList: rule.fileList,
phase: rule.extra?.['phase'] ?? 0,
Expand Down
26 changes: 24 additions & 2 deletions src/extensions/mod_management/util/testModReference.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { log } from '../../../util/log';
import { truthy } from '../../../util/util';

import { IMod, IModReference } from '../types/IMod';
import { log } from '../../../util/log';

import { IMod, IModReference, IFileListItem } from '../types/IMod';

import * as _ from 'lodash';
import minimatch from 'minimatch';
Expand All @@ -23,6 +24,9 @@ export interface IModLookupInfo {
modId?: string;
source?: string;
referenceTag?: string;
installerChoices?: any;
patches?: any;
fileList?: IFileListItem[];
}

// test if the reference is by id only, meaning it is only useful in the current setup
Expand Down Expand Up @@ -123,6 +127,21 @@ function testRef(mod: IModLookupInfo, modId: string, ref: IModReference,
return false;
}

// Right installer choices?
if ((ref.installerChoices !== undefined) && (!_.isEqual(ref.installerChoices, mod.installerChoices))) {
return false;
}

// Right hashes?
if ((ref.fileList !== undefined) && (!_.isEqual(ref.fileList, mod.fileList))) {
return false;
}

// Right patches?
if ((ref.patches !== undefined) && (!_.isEqual(ref.patches, mod.patches))) {
return false;
}

if (ref.tag !== undefined) {
if (mod.referenceTag === ref.tag) {
return true;
Expand Down Expand Up @@ -233,6 +252,9 @@ export function testModReference(mod: IMod | IModLookupInfo, reference: IModRefe
return false;
}

if (mod['patches'] !== undefined) {
log('info', 'mod has patches', { mod });
}
if ((mod as any).attributes) {
return testRef((mod as IMod).attributes as IModLookupInfo, mod.id,
reference, source, fuzzyVersion);
Expand Down

0 comments on commit fafff95

Please sign in to comment.