File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -479,14 +479,33 @@ export class AfcService {
479479 log . debug ( `Successfully pushed file to '${ remoteDst } '` ) ;
480480 }
481481
482+ /**
483+ * Recursively list `root` and everything below it. Untraversable directories are skipped
484+ * rather than aborting the walk: the media sandbox exposes directories it refuses to read
485+ * (e.g. `/PhotoData/UBF` answers GET_FILE_INFO but fails READ_DIR with PERM_DENIED).
486+ */
482487 async walk ( root : string ) : Promise < Array < { dir : string ; dirs : string [ ] ; files : string [ ] } > > {
483488 const out : Array < { dir : string ; dirs : string [ ] ; files : string [ ] } > = [ ] ;
484- const entries = await this . listdir ( root ) ;
489+ let entries : string [ ] ;
490+ try {
491+ entries = await this . listdir ( root ) ;
492+ } catch ( error ) {
493+ log . debug ( `Skipping '${ root } ' during walk, cannot list it:` , error ) ;
494+ return out ;
495+ }
485496 const dirs : string [ ] = [ ] ;
486497 const files : string [ ] = [ ] ;
487498 for ( const e of entries ) {
488499 const p = path . posix . join ( root , e ) ;
489- if ( await this . isdir ( p ) ) {
500+ let isDir : boolean ;
501+ try {
502+ isDir = await this . isdir ( p ) ;
503+ } catch ( error ) {
504+ // Unstattable entry: report it, but do not try to descend into it.
505+ log . debug ( `Cannot stat '${ p } ' during walk, treating it as a file:` , error ) ;
506+ isDir = false ;
507+ }
508+ if ( isDir ) {
490509 dirs . push ( e ) ;
491510 } else {
492511 files . push ( e ) ;
You can’t perform that action at this time.
0 commit comments