@@ -87,7 +87,7 @@ app.get('/upnp/open', function (req, res) {
8787  } ) ; 
8888} ) 
8989app . get ( '/upnp/local' ,  function  ( req ,  res )  { 
90-   res . send ( { ip :getIP ( ) , port :httpPort , https :httpsPort } ) ; 
90+   res . send ( { ip :getIP ( ) [ 0 ] , port :httpPort , https :httpsPort } ) ; 
9191} ) 
9292app . get ( '/upnp/check' ,  function  ( req ,  res )  { 
9393  natClient . getMappings ( function ( err ,  results )  { 
@@ -311,6 +311,7 @@ app.get('/restore/:path', function (req, res) {
311311  var  p = atob ( decodeURI ( req . params . path ) ) . toString ( ) ; 
312312  git . root ( ) 
313313  . then ( root => path . join ( root , store , p ) ) 
314+   . then ( dir => promisify ( fs . stat ) ( dir ) . catch ( a => { throw  'no files' ; } ) . then ( a => dir ) ) 
314315  . then ( walk ) 
315316  . then ( files => { 
316317    var  up = files 
@@ -325,15 +326,16 @@ app.get('/restore/:path', function (req, res) {
325326    //return (uploadFiles(up)); 
326327    return  uploadFiles ( up ) . then ( up => Promise . all ( [ ...up , ...cp ] ) ) ; 
327328  } ) 
328- //  .then(e=>res.status(403).send(e)) 
329329  . then ( a => res . send ( a ) ) 
330330  . catch ( e => res . status ( 403 ) . send ( e ) ) 
331331} ) ; 
332332app . get ( '/saved' ,  function  ( req ,  res )  { 
333333  git . root ( ) 
334334  . then ( root => { 
335-     var  ex = path . join ( root , store ) 
336-     return  walk ( ex ) 
335+     var  ex = path . join ( root , store ) ; 
336+     return  Promise . resolve ( ex ) 
337+     . then ( dir => promisify ( fs . stat ) ( dir ) . catch ( a => { throw  'no files' ; } ) . then ( a => dir ) ) 
338+     . then ( walk ) 
337339    . then ( a => a . filter ( i => / C o n f i g u r a t i o n ( _ a d v ) ? \. h / . test ( i ) ) ) 
338340    . then ( a => a . map ( i => path . parse ( path . relative ( ex , i ) ) . dir ) ) 
339341    . then ( unique ) 
@@ -354,6 +356,7 @@ app.get('/saved', function (req, res) {
354356      return  { tree :recurseObj ( obj ) , info :info } ; 
355357    } ) 
356358    . then ( a => res . send ( a ) ) 
359+     . catch ( e => res . status ( 403 ) . send ( e ) ) 
357360  } ) 
358361} ) ; 
359362
@@ -439,6 +442,7 @@ app.get('/pio/:env/:port', function (req, res) {
439442    params . push ( '-e' , req . params . env ) ; 
440443  if  ( close ) 
441444    params . push ( '--upload-port' , port ) 
445+   console . log ( params ) ;  //if removed - process hangs :) 
442446  ( close && serial_enabled ?serial . close ( port ) :Promise . resolve ( true ) ) 
443447  . then ( pioRoot ) 
444448  . then ( root => { 
0 commit comments