@@ -24,13 +24,17 @@ interface DownloadProgress {
24
24
profile : ImmutableProfile ;
25
25
modName : string ;
26
26
downloadProgress : number ;
27
+ downloadedSize : number ;
28
+ totalDownloadSize : number ;
27
29
installProgress : number ;
28
30
status : DownloadStatusEnum ;
29
31
}
30
32
31
33
interface UpdateObject {
32
34
downloadId : UUID ;
33
35
downloadProgress ?: number ;
36
+ downloadedSize ?: number ;
37
+ totalDownloadSize ?: number ;
34
38
installProgress ?: number ;
35
39
modName ?: string ;
36
40
status ?: DownloadStatusEnum ;
@@ -93,6 +97,8 @@ export const DownloadModule = {
93
97
profile,
94
98
modName : '' ,
95
99
downloadProgress : 0 ,
100
+ downloadedSize : 0 ,
101
+ totalDownloadSize : 0 ,
96
102
installProgress : 0 ,
97
103
status : DownloadStatusEnum . DOWNLOADING
98
104
} ;
@@ -106,7 +112,7 @@ export const DownloadModule = {
106
112
commit ( 'setIgnoreCacheVuexOnly' , settings . getContext ( ) . global . ignoreCache ) ;
107
113
} ,
108
114
109
- async downloadAndInstallCombos ( { commit, dispatch, rootGetters} , params : {
115
+ async downloadAndInstallCombos ( { commit, dispatch, rootGetters, state } , params : {
110
116
combos : ThunderstoreCombo [ ] ,
111
117
game : Game ,
112
118
installMode : InstallMode ,
@@ -123,9 +129,15 @@ export const DownloadModule = {
123
129
downloadId = await dispatch ( '_addDownload' , { combos, installMode, game, profile } ) ;
124
130
const installedMods = throwForR2Error ( await ProfileModList . getModList ( profile ) ) ;
125
131
const modsWithDependencies = await getFullDependencyList ( combos , game , installedMods , installMode ) ;
132
+
133
+ const totalDownloadSize = await DownloadUtils . getTotalDownloadSizeInBytes ( modsWithDependencies , state . ignoreCache ) ;
134
+ commit ( 'updateDownload' , { downloadId, totalDownloadSize } ) ;
135
+
126
136
await dispatch ( '_download' , { combos : modsWithDependencies , downloadId } ) ;
137
+
127
138
commit ( 'setInstalling' , downloadId ) ;
128
139
await dispatch ( '_installModsAndResolveConflicts' , { combos : modsWithDependencies , profile, downloadId } ) ;
140
+
129
141
commit ( 'setDone' , downloadId ) ;
130
142
} catch ( e ) {
131
143
const r2Error = R2Error . fromThrownValue ( e ) ;
@@ -148,7 +160,7 @@ export const DownloadModule = {
148
160
149
161
async downloadToCache ( { state} , params : {
150
162
combos : ThunderstoreCombo [ ] ,
151
- progressCallback : ( progress : number , modName : string , status : number , err : R2Error | null ) => void
163
+ progressCallback : ( downloadedSize : number ) => void
152
164
} ) {
153
165
const { combos, progressCallback } = params ;
154
166
await ThunderstoreDownloaderProvider . instance . download ( combos , state . ignoreCache , progressCallback ) ;
@@ -162,8 +174,8 @@ export const DownloadModule = {
162
174
await ThunderstoreDownloaderProvider . instance . download (
163
175
params . combos ,
164
176
state . ignoreCache ,
165
- ( downloadProgress , modName , status , err ) => {
166
- dispatch ( '_downloadProgressCallback' , { downloadId : params . downloadId , downloadProgress , modName, status, err } ) ;
177
+ ( downloadedSize , modName , status , err ) => {
178
+ dispatch ( '_downloadProgressCallback' , { downloadId : params . downloadId , downloadedSize , modName, status, err } ) ;
167
179
}
168
180
) ;
169
181
} catch ( e ) {
@@ -198,22 +210,22 @@ export const DownloadModule = {
198
210
199
211
async _downloadProgressCallback ( { commit} , params : {
200
212
downloadId : UUID ,
201
- downloadProgress : number ,
213
+ downloadedSize : number ,
202
214
modName : string ,
203
215
status : number ,
204
216
err : R2Error | null
205
217
} ) {
206
- const { downloadId, downloadProgress , modName, status, err} = params ;
218
+ const { downloadId, downloadedSize , modName, status, err} = params ;
207
219
208
220
if ( status === StatusEnum . FAILURE ) {
209
221
commit ( 'closeDownloadProgressModal' , null , { root : true } ) ;
210
- commit ( 'setFailed' , params . downloadId ) ;
211
- if ( params . err !== null ) {
212
- DownloadUtils . addSolutionsToError ( params . err ) ;
213
- throw params . err ;
222
+ commit ( 'setFailed' , downloadId ) ;
223
+ if ( err !== null ) {
224
+ DownloadUtils . addSolutionsToError ( err ) ;
225
+ throw err ;
214
226
}
215
227
} else if ( status === StatusEnum . PENDING || status === StatusEnum . SUCCESS ) {
216
- commit ( 'updateDownload' , { downloadId, modName, downloadProgress } ) ;
228
+ commit ( 'updateDownload' , { downloadId, modName, downloadedSize } ) ;
217
229
}
218
230
} ,
219
231
} ,
@@ -269,6 +281,9 @@ export const DownloadModule = {
269
281
const index : number = getIndexOfDownloadProgress ( state . allDownloads , update . downloadId ) ;
270
282
if ( index > - 1 ) {
271
283
const newDownloads = [ ...state . allDownloads ] ;
284
+ if ( update . downloadedSize !== undefined ) {
285
+ update . downloadProgress = DownloadUtils . generateProgressPercentage ( update . downloadedSize , newDownloads [ index ] . totalDownloadSize ) ;
286
+ }
272
287
newDownloads [ index ] = { ...newDownloads [ index ] , ...update } ;
273
288
state . allDownloads = newDownloads ;
274
289
}
0 commit comments