dev: move read implementation to PuterFSProvider

This commit is contained in:
KernelDeimos
2025-11-04 13:58:46 -05:00
committed by Eric Dubé
parent db8f45f386
commit d936fc47b0
2 changed files with 42 additions and 10 deletions
@@ -112,23 +112,32 @@ class LLRead extends LLFilesystemOperation {
// if no cache attempt reading from storageProvider (s3)
const svc_mountpoint = Context.get('services').get('mountpoint');
const provider = await svc_mountpoint.get_provider(fsNode.selector);
const storage = svc_mountpoint.get_storage(provider.constructor.name);
// const storage = svc_mountpoint.get_storage(provider.constructor.name);
// 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
bucket: location.bucket,
bucket_region: location.bucket_region,
version_id,
key: location.key,
memory_file: fsNode.entry,
// const location = await fsNode.get('s3:location') ?? {};
// const stream = (await storage.create_read_stream(await fsNode.get('uid'), {
// // TODO: fs:decouple-s3
// bucket: location.bucket,
// bucket_region: location.bucket_region,
// version_id,
// key: location.key,
// memory_file: fsNode.entry,
// ...(range ? { range } : (has_range ? {
// range: `bytes=${offset}-${offset + length - 1}`,
// } : {})),
// }));
const stream = await provider.read({
context: this.context,
node: fsNode,
version_id: version_id,
...(range ? { range } : (has_range ? {
range: `bytes=${offset}-${offset + length - 1}`,
} : {})),
}));
});
// Meter ingress
const size = await (async () => {
@@ -944,6 +944,29 @@ class PuterFSProvider extends putility.AdvancedBase {
return state_upload;
}
async read({
context,
node,
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;
}
}
module.exports = {