diff --git a/src/components/views/DownloadModModal.vue b/src/components/views/DownloadModModal.vue index e6a27d0c..c9c37196 100644 --- a/src/components/views/DownloadModModal.vue +++ b/src/components/views/DownloadModModal.vue @@ -166,7 +166,7 @@ let assignId = 0; }; DownloadModModal.allVersions.push([currentAssignId, progressObject]); setTimeout(() => { - ThunderstoreDownloaderProvider.instance.download(profile, tsMod, tsVersion, thunderstorePackages, ignoreCache, (progress: number, modName: string, status: number, err: R2Error | null) => { + ThunderstoreDownloaderProvider.instance.download(profile.asImmutableProfile(), tsMod, tsVersion, thunderstorePackages, ignoreCache, (progress: number, modName: string, status: number, err: R2Error | null) => { const assignIndex = DownloadModModal.allVersions.findIndex(([number, val]) => number === currentAssignId); if (status === StatusEnum.FAILURE) { if (err !== null) { @@ -337,7 +337,7 @@ let assignId = 0; DownloadModModal.allVersions.push([currentAssignId, this.downloadObject]); this.downloadingMod = true; setTimeout(() => { - ThunderstoreDownloaderProvider.instance.download(this.profile, tsMod, tsVersion, this.thunderstorePackages, this.ignoreCache, (progress: number, modName: string, status: number, err: R2Error | null) => { + ThunderstoreDownloaderProvider.instance.download(this.profile.asImmutableProfile(), tsMod, tsVersion, this.thunderstorePackages, this.ignoreCache, (progress: number, modName: string, status: number, err: R2Error | null) => { const assignIndex = DownloadModModal.allVersions.findIndex(([number, val]) => number === currentAssignId); if (status === StatusEnum.FAILURE) { if (err !== null) { diff --git a/src/providers/ror2/downloading/ThunderstoreDownloaderProvider.ts b/src/providers/ror2/downloading/ThunderstoreDownloaderProvider.ts index 2cece8a1..190b1703 100644 --- a/src/providers/ror2/downloading/ThunderstoreDownloaderProvider.ts +++ b/src/providers/ror2/downloading/ThunderstoreDownloaderProvider.ts @@ -4,7 +4,7 @@ import ThunderstoreMod from '../../../model/ThunderstoreMod'; import ThunderstoreCombo from '../../../model/ThunderstoreCombo'; import R2Error from '../../../model/errors/R2Error'; import ExportMod from '../../../model/exports/ExportMod'; -import Profile from '../../../model/Profile'; +import Profile, { ImmutableProfile } from '../../../model/Profile'; export default abstract class ThunderstoreDownloaderProvider { @@ -58,6 +58,7 @@ export default abstract class ThunderstoreDownloaderProvider { /** * A top-level method to download the latest version of a mod including its dependencies. * + * @param profile The profile the mod is downloaded for (needed to prevent dependencies from updating existing mods). * @param mod The mod to be downloaded. * @param modVersion The version of the mod to download. * @param allMods An array of all mods available from the Thunderstore API. @@ -65,7 +66,8 @@ export default abstract class ThunderstoreDownloaderProvider { * @param callback Callback to show the current state of the downloads. * @param completedCallback Callback to perform final actions against. Only called if {@param callback} has not returned a failed status. */ - public abstract download(profile: Profile, mod: ThunderstoreMod, modVersion: ThunderstoreVersion, allMods: ThunderstoreMod[], ignoreCache: boolean, + public abstract download(profile: ImmutableProfile, mod: ThunderstoreMod, modVersion: ThunderstoreVersion, + allMods: ThunderstoreMod[], ignoreCache: boolean, callback: (progress: number, modName: string, status: number, err: R2Error | null) => void, completedCallback: (modList: ThunderstoreCombo[]) => void): void; diff --git a/src/r2mm/downloading/BetterThunderstoreDownloader.ts b/src/r2mm/downloading/BetterThunderstoreDownloader.ts index 84fcc36d..0484e7d0 100644 --- a/src/r2mm/downloading/BetterThunderstoreDownloader.ts +++ b/src/r2mm/downloading/BetterThunderstoreDownloader.ts @@ -10,7 +10,7 @@ import PathResolver from '../../r2mm/manager/PathResolver'; import * as path from 'path'; import FsProvider from '../../providers/generic/file/FsProvider'; import FileWriteError from '../../model/errors/FileWriteError'; -import Profile from '../../model/Profile'; +import { ImmutableProfile } from '../../model/Profile'; import ExportMod from '../../model/exports/ExportMod'; import ThunderstoreDownloaderProvider from '../../providers/ror2/downloading/ThunderstoreDownloaderProvider'; import ManagerInformation from '../../_managerinf/ManagerInformation'; @@ -117,7 +117,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader }); } - public async download(profile: Profile, mod: ThunderstoreMod, modVersion: ThunderstoreVersion, + public async download(profile: ImmutableProfile, mod: ThunderstoreMod, modVersion: ThunderstoreVersion, allMods: ThunderstoreMod[], ignoreCache: boolean, callback: (progress: number, modName: string, status: number, err: R2Error | null) => void, completedCallback: (modList: ThunderstoreCombo[]) => void) { @@ -128,7 +128,7 @@ export default class BetterThunderstoreDownloader extends ThunderstoreDownloader combo.setVersion(modVersion); let downloadCount = 0; - const modList = await ProfileModList.getModList(profile.asImmutableProfile()); + const modList = await ProfileModList.getModList(profile); if (modList instanceof R2Error) { return callback(0, mod.getName(), StatusEnum.FAILURE, modList); }