@@ -32,53 +32,63 @@ export default SYNOCOMMUNITY.RRManager.UpdateHelper = {
3232 MAX_POST_FILESIZE : Ext . isWebKit
3333 ? - 1
3434 : window . console && window . console . firebug
35- ? 20971521
36- : 4294963200 ,
35+ ? 20971521
36+ : 4294963200 ,
3737 onRunRrUpdateManuallyClick : async function ( updateFilePath ) {
3838 const rrConfigJson = localStorage . getItem ( 'rrConfig' ) ;
3939 const rrConfig = JSON . parse ( rrConfigJson ) ;
4040
4141 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' ) ;
5449 } ,
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+ }
5863 } ) ;
5964 } ;
6065
6166 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' ) ;
7878 } ,
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+ }
8292 } ) ;
8393 } ;
8494
@@ -107,51 +117,59 @@ export default SYNOCOMMUNITY.RRManager.UpdateHelper = {
107117 let countUpdatesStatusAttemp = 0 ;
108118
109119 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 ,
135132 this . helper . formatString (
136133 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'
140138 ) ;
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 ) ;
143161 this . helper . unmask ( this . appWin ) ;
144- this . showMsg ( this . helper . V ( 'upload_file_dialog' , 'update_rr_completed' ) ) ;
162+ this . showMsg ( `Error in checkUpdateStatus: ${ error } ` ) ;
145163 return false ;
146164 }
147- return true ;
148165 } ;
149166
150167 while ( await checkUpdateStatus ( ) ) {
151168 await new Promise ( resolve => setTimeout ( resolve , 1500 ) ) ;
152169 }
153170 }
154171 } catch ( error ) {
172+ console . error ( 'Error in onRunRrUpdateManuallyClick:' , error ) ;
155173 this . showMsg ( `Error. ${ error } ` ) ;
156174 }
157175 }
0 commit comments