@@ -44,9 +44,14 @@ export async function exportModsToCombos(exportMods: ExportMod[], community: str
44
44
return combos ;
45
45
}
46
46
47
- export async function extractImportedProfileConfigs ( file : string , profileName : string ) {
48
- const entries = await ZipProvider . instance . getEntries ( file ) ;
49
- for ( const entry of entries ) {
47
+ async function extractImportedProfileConfigs (
48
+ file : string ,
49
+ profileName : string ,
50
+ progressCallback : ( status : string ) => void
51
+ ) {
52
+ const zipEntries = await ZipProvider . instance . getEntries ( file ) ;
53
+
54
+ for ( const [ index , entry ] of zipEntries . entries ( ) ) {
50
55
if ( entry . entryName . startsWith ( 'config/' ) || entry . entryName . startsWith ( "config\\" ) ) {
51
56
await ZipProvider . instance . extractEntryTo (
52
57
file ,
@@ -67,13 +72,21 @@ export async function extractImportedProfileConfigs(file: string, profileName: s
67
72
)
68
73
)
69
74
}
75
+
76
+ const progress = Math . floor ( ( index / zipEntries . length ) * 100 ) ;
77
+ progressCallback ( `Copying configs to profile: ${ progress } %` ) ;
70
78
}
71
79
}
72
80
73
- export async function installModsToProfile ( comboList : ThunderstoreCombo [ ] , modList : ExportMod [ ] , profile : ImmutableProfile ) {
81
+ async function installModsToProfile (
82
+ comboList : ThunderstoreCombo [ ] ,
83
+ modList : ExportMod [ ] ,
84
+ profile : ImmutableProfile ,
85
+ progressCallback : ( status : string ) => void
86
+ ) {
74
87
const disabledMods = modList . filter ( ( m ) => ! m . isEnabled ( ) ) . map ( ( m ) => m . getName ( ) ) ;
75
88
76
- for ( const comboMod of comboList ) {
89
+ for ( const [ index , comboMod ] of comboList . entries ( ) ) {
77
90
const manifestMod : ManifestV2 = new ManifestV2 ( ) . fromThunderstoreMod ( comboMod . getMod ( ) , comboMod . getVersion ( ) ) ;
78
91
79
92
const installError : R2Error | null = await ProfileInstallerProvider . instance . installMod ( manifestMod , profile ) ;
@@ -94,6 +107,9 @@ export async function installModsToProfile(comboList: ThunderstoreCombo[], modLi
94
107
modToDisable . disable ( ) ;
95
108
} ) ;
96
109
}
110
+
111
+ const progress = Math . floor ( ( index / comboList . length ) * 100 ) ;
112
+ progressCallback ( `Copying mods to profile: ${ progress } %` ) ;
97
113
}
98
114
}
99
115
@@ -127,18 +143,21 @@ export async function populateImportedProfile(
127
143
exportModList : ExportMod [ ] ,
128
144
profileName : string ,
129
145
isUpdate : boolean ,
130
- zipPath : string
146
+ zipPath : string ,
147
+ progressCallback : ( status : string ) => void
131
148
) {
132
149
const profile = new ImmutableProfile ( isUpdate ? '_profile_update' : profileName ) ;
133
150
134
151
if ( isUpdate ) {
152
+ progressCallback ( 'Cleaning up...' ) ;
135
153
await FileUtils . recursiveRemoveDirectoryIfExists ( profile . getProfilePath ( ) ) ;
136
154
}
137
155
138
- await installModsToProfile ( comboList , exportModList , profile ) ;
139
- await extractImportedProfileConfigs ( zipPath , profile . getProfileName ( ) ) ;
156
+ await installModsToProfile ( comboList , exportModList , profile , progressCallback ) ;
157
+ await extractImportedProfileConfigs ( zipPath , profile . getProfileName ( ) , progressCallback ) ;
140
158
141
159
if ( isUpdate ) {
160
+ progressCallback ( 'Applying changes to updated profile...' ) ;
142
161
const targetProfile = new ImmutableProfile ( profileName ) ;
143
162
await FileUtils . recursiveRemoveDirectoryIfExists ( targetProfile . getProfilePath ( ) ) ;
144
163
await FsProvider . instance . rename ( profile . getProfilePath ( ) , targetProfile . getProfilePath ( ) ) ;
0 commit comments