mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
dev: update FileFacade to use LLRead
This commit is contained in:
parent
8b11937365
commit
a225ee8d10
@ -644,6 +644,10 @@ module.exports = class FSNodeContext {
|
|||||||
if ( ! await this.exists() ) {
|
if ( ! await this.exists() ) {
|
||||||
throw new Error('file does not exist');
|
throw new Error('file does not exist');
|
||||||
}
|
}
|
||||||
|
// return null for local filesystem
|
||||||
|
if ( ! this.entry.bucket ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
bucket: this.entry.bucket,
|
bucket: this.entry.bucket,
|
||||||
bucket_region: this.entry.bucket_region,
|
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 { 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'), {
|
const stream = (await storage.create_read_stream(await fsNode.get('uid'), {
|
||||||
// TODO: fs:decouple-s3
|
// TODO: fs:decouple-s3
|
||||||
|
@ -21,6 +21,7 @@ const { Context } = require("../../util/context");
|
|||||||
const { MultiValue } = require("../../util/multivalue");
|
const { MultiValue } = require("../../util/multivalue");
|
||||||
const { stream_to_buffer } = require("../../util/streamutil");
|
const { stream_to_buffer } = require("../../util/streamutil");
|
||||||
const { PassThrough } = require("stream");
|
const { PassThrough } = require("stream");
|
||||||
|
const { LLRead } = require("../../filesystem/ll_operations/ll_read");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileFacade
|
* FileFacade
|
||||||
@ -77,17 +78,14 @@ class FileFacade extends AdvancedBase {
|
|||||||
if ( ! await fsNode.exists() ) return null;
|
if ( ! await fsNode.exists() ) return null;
|
||||||
|
|
||||||
const context = Context.get();
|
const context = Context.get();
|
||||||
const services = context.get('services');
|
|
||||||
const svc_filesystem = services.get('filesystem');
|
|
||||||
|
|
||||||
const dst_stream = new PassThrough();
|
const ll_read = new LLRead();
|
||||||
|
const stream = await ll_read.run({
|
||||||
svc_filesystem.read(context, dst_stream, {
|
actor: context.get('actor'),
|
||||||
fsNode,
|
fsNode,
|
||||||
user: context.get('user'),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return dst_stream;
|
return stream;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.values.add_factory('stream', 'web_url', async web_url => {
|
this.values.add_factory('stream', 'web_url', async web_url => {
|
||||||
|
Loading…
Reference in New Issue
Block a user