@@ -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 ;
@@ -77,12 +81,12 @@ export const DownloadModule = {
77
81
dispatch ( 'retryDownload' , { download } ) ;
78
82
} ,
79
83
80
- _addDownload ( { state} , params : {
84
+ async _addDownload ( { state, rootGetters } , params : {
81
85
combos : ThunderstoreCombo [ ] ,
82
86
installMode : InstallMode ,
83
87
game : Game ,
84
88
profile : ImmutableProfile
85
- } ) : UUID {
89
+ } ) : Promise < UUID > {
86
90
const { combos, installMode, game, profile } = params ;
87
91
const downloadId = UUID . create ( ) ;
88
92
const downloadObject : DownloadProgress = {
@@ -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
} ;
@@ -115,6 +121,7 @@ export const DownloadModule = {
115
121
} ) {
116
122
const { combos, game, installMode, profile, hideModal } = params ;
117
123
let downloadId : UUID | undefined ;
124
+ const settings : ManagerSettings = rootGetters [ 'settings' ] ;
118
125
119
126
try {
120
127
if ( ! hideModal ) {
@@ -123,6 +130,7 @@ export const DownloadModule = {
123
130
downloadId = await dispatch ( '_addDownload' , { combos, installMode, game, profile } ) ;
124
131
const installedMods = throwForR2Error ( await ProfileModList . getModList ( profile ) ) ;
125
132
const modsWithDependencies = await getFullDependencyList ( combos , game , installedMods , installMode ) ;
133
+ commit ( 'updateDownload' , { downloadId, totalDownloadSize : await ThunderstoreDownloaderProvider . instance . getTotalDownloadSizeInBytes ( modsWithDependencies , settings ) } ) ;
126
134
await dispatch ( '_download' , { combos : modsWithDependencies , downloadId } ) ;
127
135
commit ( 'setInstalling' , downloadId ) ;
128
136
await dispatch ( '_installModsAndResolveConflicts' , { combos : modsWithDependencies , profile, downloadId } ) ;
@@ -146,24 +154,25 @@ export const DownloadModule = {
146
154
}
147
155
} ,
148
156
149
- async downloadToCache ( { state} , params : {
157
+ async downloadToCache ( { state, rootGetters } , params : {
150
158
combos : ThunderstoreCombo [ ] ,
151
- progressCallback : ( progress : number , modName : string , status : number , err : R2Error | null ) => void
159
+ progressCallback : ( progress : number , downloadedSize : number , totalDownloadSize : number , modName : string , status : number , err : R2Error | null ) => void
152
160
} ) {
153
161
const { combos, progressCallback } = params ;
154
- await ThunderstoreDownloaderProvider . instance . download ( combos , state . ignoreCache , progressCallback ) ;
162
+ await ThunderstoreDownloaderProvider . instance . download ( combos , state . ignoreCache , rootGetters [ 'settings' ] , progressCallback ) ;
155
163
} ,
156
164
157
- async _download ( { state, commit, dispatch} , params : {
165
+ async _download ( { state, commit, dispatch, rootGetters } , params : {
158
166
combos : ThunderstoreCombo [ ] ,
159
167
downloadId : UUID
160
168
} ) {
161
169
try {
162
170
await ThunderstoreDownloaderProvider . instance . download (
163
171
params . combos ,
164
172
state . ignoreCache ,
165
- ( downloadProgress , modName , status , err ) => {
166
- dispatch ( '_downloadProgressCallback' , { downloadId : params . downloadId , downloadProgress, modName, status, err } ) ;
173
+ rootGetters [ 'settings' ] ,
174
+ ( progress , downloadedSize , totalDownloadSize , modName , status , err ) => {
175
+ dispatch ( '_downloadProgressCallback' , { downloadId : params . downloadId , downloadProgress : progress , downloadedSize, totalDownloadSize, modName, status, err } ) ;
167
176
}
168
177
) ;
169
178
} catch ( e ) {
@@ -199,21 +208,23 @@ export const DownloadModule = {
199
208
async _downloadProgressCallback ( { commit} , params : {
200
209
downloadId : UUID ,
201
210
downloadProgress : number ,
211
+ downloadedSize : number ,
212
+ totalDownloadSize : number ,
202
213
modName : string ,
203
- status : number ,
214
+ status : DownloadStatusEnum ,
204
215
err : R2Error | null
205
216
} ) {
206
- const { downloadId, downloadProgress, modName, status, err} = params ;
217
+ const { downloadId, downloadProgress, downloadedSize , totalDownloadSize , modName, status, err} = params ;
207
218
208
219
if ( status === StatusEnum . FAILURE ) {
209
220
commit ( 'closeDownloadProgressModal' , null , { root : true } ) ;
210
- commit ( 'setFailed' , params . downloadId ) ;
211
- if ( params . err !== null ) {
212
- DownloadUtils . addSolutionsToError ( params . err ) ;
213
- throw params . err ;
221
+ commit ( 'setFailed' , downloadId ) ;
222
+ if ( err !== null ) {
223
+ DownloadUtils . addSolutionsToError ( err ) ;
224
+ throw err ;
214
225
}
215
226
} else if ( status === StatusEnum . PENDING || status === StatusEnum . SUCCESS ) {
216
- commit ( 'updateDownload' , { downloadId, modName, downloadProgress } ) ;
227
+ commit ( 'updateDownload' , { downloadId, modName, downloadProgress, downloadedSize , totalDownloadSize } ) ;
217
228
}
218
229
} ,
219
230
} ,
0 commit comments