@@ -44,16 +44,7 @@ export default class ProfileModList {
44
44
const value = ( yaml . parse ( ( await fs . readFile ( profile . joinToProfilePath ( 'mods.yml' ) ) ) . toString ( ) ) || [ ] ) ;
45
45
for ( let modIndex in value ) {
46
46
const mod = new ManifestV2 ( ) . fromReactive ( value [ modIndex ] ) ;
47
- let iconPath = path . resolve ( profile . getProfilePath ( ) , "BepInEx" , "plugins" , mod . getName ( ) , "icon.png" ) ;
48
-
49
- // BepInEx is not a plugin, and so the only place where we can get its icon is from the cache.
50
- // Also non-BepInEx games, e.g. ReturnOfModding games, read the icons from cache. This could
51
- // be fixed using a different path though.
52
- if ( ! ( await fs . exists ( iconPath ) ) ) {
53
- iconPath = path . join ( PathResolver . MOD_ROOT , "cache" , mod . getName ( ) , mod . getVersionNumber ( ) . toString ( ) , "icon.png" ) ;
54
- }
55
-
56
- mod . setIcon ( iconPath ) ;
47
+ await this . setIconPath ( mod , profile ) ;
57
48
value [ modIndex ] = mod ;
58
49
}
59
50
return value ;
@@ -280,4 +271,16 @@ export default class ProfileModList {
280
271
return modList . filter ( value => ! value . isEnabled ( ) ) . length ;
281
272
}
282
273
274
+ public static async setIconPath ( mod : ManifestV2 , profile : ImmutableProfile ) : Promise < void > {
275
+ let iconPath = path . resolve ( profile . getProfilePath ( ) , "BepInEx" , "plugins" , mod . getName ( ) , "icon.png" ) ;
276
+
277
+ // BepInEx is not a plugin, and so the only place where we can get its icon is from the cache.
278
+ // Also non-BepInEx games, e.g. ReturnOfModding games, read the icons from cache. This could
279
+ // be fixed using a different path though.
280
+ if ( ! ( await FsProvider . instance . exists ( iconPath ) ) ) {
281
+ iconPath = path . join ( PathResolver . MOD_ROOT , "cache" , mod . getName ( ) , mod . getVersionNumber ( ) . toString ( ) , "icon.png" ) ;
282
+ }
283
+
284
+ mod . setIcon ( iconPath ) ;
285
+ }
283
286
}
0 commit comments