dev: update FileFacade to use LLRead

This commit is contained in:
KernelDeimos 2024-07-31 23:20:27 -04:00 committed by Eric Dubé
parent 475eb13fb3
commit 1f059c330c
3 changed files with 13 additions and 8 deletions

View File

@ -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,

View File

@ -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

View File

@ -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 => {