@@ -908,52 +908,53 @@ export class ObjectsInMemoryServer extends ObjectsInMemoryJsonlDB {
908908 return void handler . sendArray ( responseId , isScan ? [ '0' , response ] : response ) ;
909909 }
910910 }
911+
911912 if ( namespace === this . namespaceFile || namespace === this . namespaceObjects ) {
913+ if ( isMeta !== undefined ) {
914+ // such a request should never happen
915+ return handler . sendArray ( responseId , isScan ? [ '0' , [ ] ] : [ ] ) ; // send out file or full db response
916+ }
917+
912918 // Handle request to get meta data keys
913- if ( isMeta === undefined ) {
914- let res ;
915- try {
916- res = this . _readDir ( id , name ) ;
917- if ( ! res || ! res . length ) {
918- res = [
919- {
920- file : '_data.json' ,
921- stats : { } ,
922- isDir : false ,
923- virtualFile : true ,
924- notExists : true ,
925- } ,
926- ] ;
927- }
928- } catch ( e ) {
929- if ( ! e . message . endsWith ( utils . ERRORS . ERROR_NOT_FOUND ) ) {
930- return void handler . sendError ( responseId , new Error ( `ERROR readDir id=${ id } : ${ e . message } ` ) ) ;
931- }
932- res = [ ] ;
919+ let res ;
920+ try {
921+ res = this . _readDir ( id , name ) ;
922+ if ( ! res || ! res . length ) {
923+ res = [
924+ {
925+ file : '_data.json' ,
926+ stats : { } ,
927+ isDir : false ,
928+ virtualFile : true ,
929+ notExists : true ,
930+ } ,
931+ ] ;
933932 }
934- let baseName = name || '' ;
935- if ( baseName . length && ! baseName . endsWith ( '/' ) ) {
936- baseName += '/' ;
933+ } catch ( e ) {
934+ if ( ! e . message . endsWith ( utils . ERRORS . ERROR_NOT_FOUND ) ) {
935+ return void handler . sendError ( responseId , new Error ( `ERROR readDir id= ${ id } : ${ e . message } ` ) ) ;
937936 }
938- res . forEach ( arr => {
939- let entryId = id ;
940- if ( arr . isDir ) {
941- if ( entryId === '' || entryId === '*' ) {
942- entryId = arr . file ;
943- arr . file = '_data.json' ; // We return a "virtual file" to mark the directory as existing
944- } else {
945- arr . file += '/_data.json' ; // We return a "virtual file" to mark the directory as existing
946- }
947- }
948- // We need to simulate the Meta data here, so return both
949- response . push ( this . getFileId ( entryId , baseName + arr . file , true ) ) ;
950- response . push ( this . getFileId ( entryId , baseName + arr . file , false ) ) ;
951- } ) ;
952- handler . sendArray ( responseId , isScan ? [ '0' , response ] : response ) ; // send out file or full db response
953- } else {
954- // such a request should never happen
955- handler . sendArray ( responseId , isScan ? [ '0' , [ ] ] : [ ] ) ; // send out file or full db response
937+ res = [ ] ;
956938 }
939+ let baseName = name || '' ;
940+ if ( baseName . length && ! baseName . endsWith ( '/' ) ) {
941+ baseName += '/' ;
942+ }
943+ res . forEach ( arr => {
944+ let entryId = id ;
945+ if ( arr . isDir ) {
946+ if ( entryId === '' || entryId === '*' ) {
947+ entryId = arr . file ;
948+ arr . file = '_data.json' ; // We return a "virtual file" to mark the directory as existing
949+ } else {
950+ arr . file += '/_data.json' ; // We return a "virtual file" to mark the directory as existing
951+ }
952+ }
953+ // We need to simulate the Meta data here, so return both
954+ response . push ( this . getFileId ( entryId , baseName + arr . file , true ) ) ;
955+ response . push ( this . getFileId ( entryId , baseName + arr . file , false ) ) ;
956+ } ) ;
957+ handler . sendArray ( responseId , isScan ? [ '0' , response ] : response ) ; // send out file or full db response
957958 } else if ( namespace === this . namespaceSet ) {
958959 handler . sendArray ( responseId , isScan ? [ '0' , [ ] ] : [ ] ) ; // send out empty array, we have no sets
959960 } else {
0 commit comments