@@ -32,53 +32,63 @@ export default SYNOCOMMUNITY.RRManager.UpdateHelper = {
32
32
MAX_POST_FILESIZE : Ext . isWebKit
33
33
? - 1
34
34
: window . console && window . console . firebug
35
- ? 20971521
36
- : 4294963200 ,
35
+ ? 20971521
36
+ : 4294963200 ,
37
37
onRunRrUpdateManuallyClick : async function ( updateFilePath ) {
38
38
const rrConfigJson = localStorage . getItem ( 'rrConfig' ) ;
39
39
const rrConfig = JSON . parse ( rrConfigJson ) ;
40
40
41
41
const confirmUpload = ( ) => {
42
- return new Promise ( ( resolve ) => {
43
- this . appWin . getMsgBox ( ) . confirmDelete (
44
- 'Confirm' ,
45
- this . helper . V ( 'upload_file_dialog' , 'file_uploading_succesfull_msg' ) ,
46
- result => {
47
- resolve ( result === 'yes' ) ;
48
- } ,
49
- null ,
50
- {
51
- yes : {
52
- text : this . helper . T ( 'common' , 'yes' ) ,
53
- btnStyle : 'red' ,
42
+ return new Promise ( ( resolve , reject ) => {
43
+ try {
44
+ this . appWin . getMsgBox ( ) . confirmDelete (
45
+ 'Confirm' ,
46
+ this . helper . V ( 'upload_file_dialog' , 'file_uploading_succesfull_msg' ) ,
47
+ result => {
48
+ resolve ( result === 'yes' ) ;
54
49
} ,
55
- no : { text : Ext . MessageBox . buttonText . no } ,
56
- }
57
- ) ;
50
+ null ,
51
+ {
52
+ yes : {
53
+ text : this . helper . T ( 'common' , 'yes' ) ,
54
+ btnStyle : 'red' ,
55
+ } ,
56
+ no : { text : Ext . MessageBox . buttonText . no } ,
57
+ }
58
+ ) ;
59
+ } catch ( error ) {
60
+ console . error ( 'Error in confirmUpload:' , error ) ;
61
+ reject ( error ) ;
62
+ }
58
63
} ) ;
59
64
} ;
60
65
61
66
const confirmUpdate = ( currentRrVersion , updateRrVersion ) => {
62
- return new Promise ( ( resolve ) => {
63
- this . appWin . getMsgBox ( ) . confirmDelete (
64
- 'Confirmation' ,
65
- this . helper . formatString (
66
- this . helper . V ( 'upload_file_dialog' , 'update_rr_confirmation' ) ,
67
- currentRrVersion ,
68
- updateRrVersion
69
- ) ,
70
- userResponse => {
71
- resolve ( userResponse === 'yes' ) ;
72
- } ,
73
- null ,
74
- {
75
- yes : {
76
- text : this . helper . V ( 'upload_file_dialog' , 'btn_proceed' ) ,
77
- btnStyle : 'red' ,
67
+ return new Promise ( ( resolve , reject ) => {
68
+ try {
69
+ this . appWin . getMsgBox ( ) . confirmDelete (
70
+ 'Confirmation' ,
71
+ this . helper . formatString (
72
+ this . helper . V ( 'upload_file_dialog' , 'update_rr_confirmation' ) ,
73
+ currentRrVersion ,
74
+ updateRrVersion
75
+ ) ,
76
+ userResponse => {
77
+ resolve ( userResponse === 'yes' ) ;
78
78
} ,
79
- no : { text : this . helper . T ( 'common' , 'cancel' ) } ,
80
- }
81
- ) ;
79
+ null ,
80
+ {
81
+ yes : {
82
+ text : this . helper . V ( 'upload_file_dialog' , 'btn_proceed' ) ,
83
+ btnStyle : 'red' ,
84
+ } ,
85
+ no : { text : this . helper . T ( 'common' , 'cancel' ) } ,
86
+ }
87
+ ) ;
88
+ } catch ( error ) {
89
+ console . error ( 'Error in confirmUpdate:' , error ) ;
90
+ reject ( error ) ;
91
+ }
82
92
} ) ;
83
93
} ;
84
94
@@ -107,51 +117,59 @@ export default SYNOCOMMUNITY.RRManager.UpdateHelper = {
107
117
let countUpdatesStatusAttemp = 0 ;
108
118
109
119
const checkUpdateStatus = async ( ) => {
110
- const checksStatusResponse = await this . apiProvider . callCustomScript (
111
- 'checkUpdateStatus.cgi?filename=rr_update_progress'
112
- ) ;
113
- if ( ! checksStatusResponse ?. success ) {
114
- this . helper . unmask ( this . appWin ) ;
115
- this . showMsg ( checksStatusResponse ?. status ) ;
116
- return false ;
117
- }
118
- const response = checksStatusResponse . result ;
119
- this . helper . mask (
120
- this . appWin ,
121
- this . helper . formatString (
122
- this . helper . V ( 'upload_file_dialog' , 'update_rr_progress_msg' ) ,
123
- response ?. progress ?? '--' ,
124
- response ?. progressmsg ?? '--'
125
- ) ,
126
- 'x-mask-loading'
127
- ) ;
128
- countUpdatesStatusAttemp ++ ;
129
- if (
130
- countUpdatesStatusAttemp === maxCountOfRefreshUpdateStatus ||
131
- response ?. progress ?. startsWith ( '-' )
132
- ) {
133
- this . helper . unmask ( this . appWin ) ;
134
- this . showMsg (
120
+ try {
121
+ const checksStatusResponse = await this . apiProvider . callCustomScript (
122
+ 'checkUpdateStatus.cgi?filename=rr_update_progress'
123
+ ) ;
124
+ if ( ! checksStatusResponse ?. success ) {
125
+ this . helper . unmask ( this . appWin ) ;
126
+ this . showMsg ( checksStatusResponse ?. status ) ;
127
+ return false ;
128
+ }
129
+ const response = checksStatusResponse . result ;
130
+ this . helper . mask (
131
+ this . appWin ,
135
132
this . helper . formatString (
136
133
this . helper . V ( 'upload_file_dialog' , 'update_rr_progress_msg' ) ,
137
- response ?. progress ,
138
- response ?. progressmsg
139
- )
134
+ response ?. progress ?? '--' ,
135
+ response ?. progressmsg ?? '--'
136
+ ) ,
137
+ 'x-mask-loading'
140
138
) ;
141
- return false ;
142
- } else if ( response ?. progress === '100' ) {
139
+ countUpdatesStatusAttemp ++ ;
140
+ if (
141
+ countUpdatesStatusAttemp === maxCountOfRefreshUpdateStatus ||
142
+ response ?. progress ?. startsWith ( '-' )
143
+ ) {
144
+ this . helper . unmask ( this . appWin ) ;
145
+ this . showMsg (
146
+ this . helper . formatString (
147
+ this . helper . V ( 'upload_file_dialog' , 'update_rr_progress_msg' ) ,
148
+ response ?. progress ,
149
+ response ?. progressmsg
150
+ )
151
+ ) ;
152
+ return false ;
153
+ } else if ( response ?. progress === '100' ) {
154
+ this . helper . unmask ( this . appWin ) ;
155
+ this . showMsg ( this . helper . V ( 'upload_file_dialog' , 'update_rr_completed' ) ) ;
156
+ return false ;
157
+ }
158
+ return true ;
159
+ } catch ( error ) {
160
+ console . error ( 'Error in checkUpdateStatus:' , error ) ;
143
161
this . helper . unmask ( this . appWin ) ;
144
- this . showMsg ( this . helper . V ( 'upload_file_dialog' , 'update_rr_completed' ) ) ;
162
+ this . showMsg ( `Error in checkUpdateStatus: ${ error } ` ) ;
145
163
return false ;
146
164
}
147
- return true ;
148
165
} ;
149
166
150
167
while ( await checkUpdateStatus ( ) ) {
151
168
await new Promise ( resolve => setTimeout ( resolve , 1500 ) ) ;
152
169
}
153
170
}
154
171
} catch ( error ) {
172
+ console . error ( 'Error in onRunRrUpdateManuallyClick:' , error ) ;
155
173
this . showMsg ( `Error. ${ error } ` ) ;
156
174
}
157
175
}
0 commit comments