diff --git a/src/backend/src/filesystem/FSNodeContext.js b/src/backend/src/filesystem/FSNodeContext.js index 28e15d6b..fe421be6 100644 --- a/src/backend/src/filesystem/FSNodeContext.js +++ b/src/backend/src/filesystem/FSNodeContext.js @@ -644,6 +644,10 @@ module.exports = class FSNodeContext { if ( ! await this.exists() ) { throw new Error('file does not exist'); } + // return null for local filesystem + if ( ! this.entry.bucket ) { + return null; + } return { bucket: this.entry.bucket, bucket_region: this.entry.bucket_region, diff --git a/src/backend/src/filesystem/ll_operations/ll_read.js b/src/backend/src/filesystem/ll_operations/ll_read.js index e19782dd..b903a9dd 100644 --- a/src/backend/src/filesystem/ll_operations/ll_read.js +++ b/src/backend/src/filesystem/ll_operations/ll_read.js @@ -120,7 +120,10 @@ class LLRead extends LLFilesystemOperation { const { fsNode, version_id, offset, length, has_range } = a.values(); - const location = await fsNode.get('s3:location'); + // Empty object here is in the case of local fiesystem, + // where s3:location will return null. + // TODO: storage interface shouldn't have S3-specific properties. + const location = await fsNode.get('s3:location') ?? {}; const stream = (await storage.create_read_stream(await fsNode.get('uid'), { // TODO: fs:decouple-s3 diff --git a/src/backend/src/services/drivers/FileFacade.js b/src/backend/src/services/drivers/FileFacade.js index 22306c34..0a6d1b1a 100644 --- a/src/backend/src/services/drivers/FileFacade.js +++ b/src/backend/src/services/drivers/FileFacade.js @@ -21,6 +21,7 @@ const { Context } = require("../../util/context"); const { MultiValue } = require("../../util/multivalue"); const { stream_to_buffer } = require("../../util/streamutil"); const { PassThrough } = require("stream"); +const { LLRead } = require("../../filesystem/ll_operations/ll_read"); /** * FileFacade @@ -77,17 +78,14 @@ class FileFacade extends AdvancedBase { if ( ! await fsNode.exists() ) return null; const context = Context.get(); - const services = context.get('services'); - const svc_filesystem = services.get('filesystem'); - const dst_stream = new PassThrough(); - - svc_filesystem.read(context, dst_stream, { + const ll_read = new LLRead(); + const stream = await ll_read.run({ + actor: context.get('actor'), fsNode, - user: context.get('user'), }); - return dst_stream; + return stream; }); this.values.add_factory('stream', 'web_url', async web_url => {