@@ -127,7 +127,7 @@ const Comms = {
127127 if ( SETTINGS . autoReload || Const . LOAD_APP_AFTER_UPLOAD || Const . SINGLE_APP_ONLY ) return Comms . write ( "\x10load()\n" ) ;
128128 else return Comms . showMessage ( Const . MESSAGE_RELOAD ) ;
129129 } ,
130- // Gets a text command to append to what's being sent to show progress. If progress==undefined, it's the first command
130+ // Gets a text command to append to what's being sent to show progress. If progress==undefined, it's the first command, otherwise it's 0..1
131131 getProgressCmd : ( progress ) => {
132132 console . log ( `<COMMS> getProgressCmd ${ progress !== undefined ?`${ Math . round ( progress * 100 ) } %` :"START" } ` ) ;
133133 if ( ! Const . HAS_E_SHOWMESSAGE ) {
@@ -273,9 +273,7 @@ const Comms = {
273273 ( options . noFinish ? Promise . resolve ( ) : Comms . showUploadFinished ( ) ) . then ( ( ) => {
274274 Progress . hide ( { sticky :true } ) ;
275275 resolve ( appInfo ) ;
276- } ) . catch ( function ( ) {
277- reject ( "" ) ;
278- } ) ;
276+ } ) . catch ( reject ) ;
279277 return ;
280278 }
281279 let f = fileContents . shift ( ) ;
@@ -285,11 +283,16 @@ const Comms = {
285283 function startUpload ( ) {
286284 console . log ( `<COMMS> Upload ${ f . name } => ${ JSON . stringify ( f . content . length > 50 ? f . content . substr ( 0 , 50 ) + "..." : f . content ) } (${ f . content . length } b${ uploadPacket ?", binary" :"" } )` ) ;
287285 if ( uploadPacket ) {
288- return Comms . getConnection ( ) . espruinoSendFile ( f . name , f . content , {
289- fs : Const . FILES_IN_FS ,
290- chunkSize : Const . PACKET_UPLOAD_CHUNKSIZE ,
291- noACK : Const . PACKET_UPLOAD_NOACK
292- } ) ;
286+ Progress . show ( { // Ensure that the correct progress is being shown in app loader
287+ percent : 0 ,
288+ min :currentBytes / maxBytes ,
289+ max :( currentBytes + f . content . length ) / maxBytes } ) ;
290+ return Comms . write ( `\x10${ Comms . getProgressCmd ( currentBytes / maxBytes ) } \n` ) . then ( ( ) => // update percent bar on Bangle.js screen
291+ Comms . getConnection ( ) . espruinoSendFile ( f . name , f . content , { // send the file
292+ fs : Const . FILES_IN_FS ,
293+ chunkSize : Const . PACKET_UPLOAD_CHUNKSIZE ,
294+ noACK : Const . PACKET_UPLOAD_NOACK
295+ } ) ) ;
293296 } else {
294297 return Comms . uploadCommandList ( f . cmd , currentBytes , maxBytes ) ;
295298 }
@@ -330,6 +333,9 @@ const Comms = {
330333 Comms . reset ( ) . then ( doUpload , reject )
331334 }
332335 } ) ;
336+ } ) . catch ( err => {
337+ Progress . hide ( { sticky :true } ) ; // ensure we hide our sticky progress message if there was an error
338+ return Promise . reject ( err ) ; // pass the error on
333339 } ) ;
334340 } ,
335341 // Get Device ID, version, storage stats, and a JSON list of installed apps
0 commit comments