1
0
Эх сурвалжийг харах

dev: update FileFacade to use LLRead

KernelDeimos 10 сар өмнө
parent
commit
1f059c330c

+ 4 - 0
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,

+ 4 - 1
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

+ 5 - 7
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 => {