mirror of
https://github.com/HeyPuter/puter.git
synced 2025-12-30 17:50:00 -06:00
dev(puterfs): move read to extension
This commit is contained in:
@@ -24,6 +24,10 @@ const svc_trace = extension.import('service:traceService');
|
||||
const svc_size = extension.import('service:sizeService');
|
||||
const svc_fsEntry = extension.import('service:fsEntryService');
|
||||
|
||||
// TODO: depending on mountpoint service will not be necessary
|
||||
// once the storage provider is moved to this extension
|
||||
const svc_mountpoint = extension.import('service:mountpoint');
|
||||
|
||||
const {
|
||||
APIError,
|
||||
Actor,
|
||||
@@ -70,6 +74,22 @@ class PuterFSProvider {
|
||||
await this.#rmnode({ context, node, options });
|
||||
}
|
||||
|
||||
async read ({ context, node, version_id, range }) {
|
||||
const svc_mountpoint = context.get('services').get('mountpoint');
|
||||
const storage = svc_mountpoint.get_storage(this.constructor.name);
|
||||
const location = await node.get('s3:location') ?? {};
|
||||
const stream = (await storage.create_read_stream(await node.get('uid'), {
|
||||
// TODO: fs:decouple-s3
|
||||
bucket: location.bucket,
|
||||
bucket_region: location.bucket_region,
|
||||
version_id,
|
||||
key: location.key,
|
||||
memory_file: node.entry,
|
||||
...(range ? { range } : {}),
|
||||
}));
|
||||
return stream;
|
||||
}
|
||||
|
||||
async #rmnode ({ node, options }) {
|
||||
// Services
|
||||
if ( !options.override_immutable && await node.get('immutable') ) {
|
||||
|
||||
@@ -885,21 +885,8 @@ class PuterFSProvider extends putility.AdvancedBase {
|
||||
version_id,
|
||||
range,
|
||||
}) {
|
||||
// TODO: one PuterFS aggregates its own storage, don't get it
|
||||
// via mountpoint service.
|
||||
const svc_mountpoint = context.get('services').get('mountpoint');
|
||||
const storage = svc_mountpoint.get_storage(this.constructor.name);
|
||||
const location = await node.get('s3:location') ?? {};
|
||||
const stream = (await storage.create_read_stream(await node.get('uid'), {
|
||||
// TODO: fs:decouple-s3
|
||||
bucket: location.bucket,
|
||||
bucket_region: location.bucket_region,
|
||||
version_id,
|
||||
key: location.key,
|
||||
memory_file: node.entry,
|
||||
...(range ? { range } : {}),
|
||||
}));
|
||||
return stream;
|
||||
console.error('This .read should not be called!');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user