dev(puterfs): move read to extension

This commit is contained in:
KernelDeimos
2025-11-05 16:13:07 -05:00
committed by Eric Dubé
parent 0fd7100795
commit f2ad7ddfb5
2 changed files with 22 additions and 15 deletions

View File

@@ -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') ) {

View File

@@ -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);
}
}