mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 14:03:42 +00:00
dev: update FileFacade to use LLRead
This commit is contained in:
parent
475eb13fb3
commit
1f059c330c
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user