1
1
import ProfileInstallerProvider from '../../../providers/ror2/installing/ProfileInstallerProvider' ;
2
2
import ManifestV2 from '../../../model/ManifestV2' ;
3
- import Profile , { ImmutableProfile } from '../../../model/Profile' ;
3
+ import { ImmutableProfile } from '../../../model/Profile' ;
4
4
import FileTree from '../../../model/file/FileTree' ;
5
5
import R2Error from '../../../model/errors/R2Error' ;
6
6
import ModLoaderPackageMapping from '../../../model/installing/ModLoaderPackageMapping' ;
@@ -157,11 +157,10 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
157
157
return this . installForManifestV2 ( args ) ;
158
158
}
159
159
160
- private getInstallArgs ( mod : ManifestV2 , profile : Profile | ImmutableProfile ) : InstallArgs {
161
- const immutable = profile instanceof Profile ? profile . asImmutableProfile ( ) : profile ;
160
+ private getInstallArgs ( mod : ManifestV2 , profile : ImmutableProfile ) : InstallArgs {
162
161
const cacheDirectory = path . join ( PathResolver . MOD_ROOT , 'cache' ) ;
163
162
const packagePath = path . join ( cacheDirectory , mod . getName ( ) , mod . getVersionNumber ( ) . toString ( ) ) ;
164
- return { mod, profile : immutable , packagePath} ;
163
+ return { mod, profile, packagePath} ;
165
164
}
166
165
167
166
private getModLoader ( mod : ManifestV2 ) : ModLoaderPackageMapping | undefined {
@@ -182,7 +181,7 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
182
181
}
183
182
}
184
183
185
- private async uninstallPackageZip ( mod : ManifestV2 , profile : Profile ) {
184
+ private async uninstallPackageZip ( mod : ManifestV2 , profile : ImmutableProfile ) {
186
185
const fs = FsProvider . instance ;
187
186
188
187
const recursiveDelete = async ( mainPath : string , match : string ) => {
@@ -200,7 +199,7 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
200
199
await recursiveDelete ( profile . getProfilePath ( ) , `${ mod . getName ( ) } .ts.zip` ) ;
201
200
}
202
201
203
- private async uninstallSubDir ( mod : ManifestV2 , profile : Profile ) : Promise < R2Error | null > {
202
+ private async uninstallSubDir ( mod : ManifestV2 , profile : ImmutableProfile ) : Promise < R2Error | null > {
204
203
const activeGame = GameManager . activeGame ;
205
204
const fs = FsProvider . instance ;
206
205
@@ -255,7 +254,7 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
255
254
return Promise . resolve ( null ) ;
256
255
}
257
256
258
- private async uninstallState ( mod : ManifestV2 , profile : Profile ) : Promise < R2Error | null > {
257
+ private async uninstallState ( mod : ManifestV2 , profile : ImmutableProfile ) : Promise < R2Error | null > {
259
258
const stateFilePath = profile . joinToProfilePath ( "_state" , `${ mod . getName ( ) } -state.yml` ) ;
260
259
if ( await FsProvider . instance . exists ( stateFilePath ) ) {
261
260
const read = await FsProvider . instance . readFile ( stateFilePath ) ;
@@ -273,7 +272,7 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
273
272
return Promise . resolve ( null ) ;
274
273
}
275
274
276
- async uninstallMod ( mod : ManifestV2 , profile : Profile ) : Promise < R2Error | null > {
275
+ async uninstallMod ( mod : ManifestV2 , profile : ImmutableProfile ) : Promise < R2Error | null > {
277
276
// Support for installer specific uninstall methods are rolled out
278
277
// gradually and therefore might not be defined yet.
279
278
try {
@@ -309,7 +308,7 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
309
308
* implements a custom uninstallation method.
310
309
* @return true if mod loader was uninstalled
311
310
*/
312
- async uninstallModLoaderWithInstaller ( mod : ManifestV2 , profile : Profile ) : Promise < boolean > {
311
+ async uninstallModLoaderWithInstaller ( mod : ManifestV2 , profile : ImmutableProfile ) : Promise < boolean > {
313
312
const modLoader = this . getModLoader ( mod ) ;
314
313
const installerId = modLoader ? GetInstallerIdForLoader ( modLoader . loaderType ) : null ;
315
314
return this . uninstallWithInstaller ( installerId , mod , profile ) ;
@@ -320,15 +319,15 @@ export default class GenericProfileInstaller extends ProfileInstallerProvider {
320
319
* uninstallation method.
321
320
* @return true if mod was uninstalled
322
321
*/
323
- async uninstallModWithInstaller ( mod : ManifestV2 , profile : Profile ) : Promise < boolean > {
322
+ async uninstallModWithInstaller ( mod : ManifestV2 , profile : ImmutableProfile ) : Promise < boolean > {
324
323
const installerId = GetInstallerIdForPlugin ( GameManager . activeGame . packageLoader ) ;
325
324
return this . uninstallWithInstaller ( installerId , mod , profile ) ;
326
325
}
327
326
328
327
private async uninstallWithInstaller (
329
328
installerId : PackageInstallerId | null ,
330
329
mod : ManifestV2 ,
331
- profile : Profile
330
+ profile : ImmutableProfile
332
331
) : Promise < boolean > {
333
332
const installer = installerId ? PackageInstallers [ installerId ] : undefined ;
334
333
0 commit comments