mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
prereq: make it possible to access storage without context init
This commit is contained in:
parent
332371fccb
commit
9ad04cd33f
@ -292,6 +292,9 @@ const install = async ({ services, app, useapi }) => {
|
||||
|
||||
const { PermissionAPIService } = require('./services/PermissionAPIService');
|
||||
services.registerService('__permission-api', PermissionAPIService);
|
||||
|
||||
const { MountpointService } = require('./services/MountpointService');
|
||||
services.registerService('mountpoint', MountpointService);
|
||||
}
|
||||
|
||||
const install_legacy = async ({ services }) => {
|
||||
|
@ -49,7 +49,8 @@ class LLWriteBase extends LLFilesystemOperation {
|
||||
const errors = svc.get('error-service').create(log);
|
||||
const svc_event = svc.get('event');
|
||||
|
||||
const storage = Context.get('storage');
|
||||
const svc_mountpoint = svc.get('mountpoint');
|
||||
const storage = svc_mountpoint.get_storage();
|
||||
|
||||
bucket ??= config.s3_bucket;
|
||||
bucket_region ??= config.s3_region;
|
||||
|
@ -1057,7 +1057,9 @@ async function deleteUser(user_id){
|
||||
for(let i=0; i<files.length; i++){
|
||||
// init S3 SDK
|
||||
const svc_fs = Context.get('services').get('filesystem');
|
||||
const storage = Context.get('storage');
|
||||
const svc_mountpoint =
|
||||
Context.get('services').get('mountpoint');
|
||||
const storage = svc_mountpoint.get_storage();
|
||||
const op_delete = storage.create_delete();
|
||||
await op_delete.run({
|
||||
node: await svc_fs.node(new NodeUIDSelector(files[i].uuid))
|
||||
|
@ -31,6 +31,9 @@ class LocalDiskStorageService extends BaseService {
|
||||
const svc_contextInit = this.services.get('context-init');
|
||||
const storage = new LocalDiskStorageStrategy({ services: this.services });
|
||||
svc_contextInit.register_value('storage', storage);
|
||||
|
||||
const svc_mountpoint = this.services.get('mountpoint');
|
||||
svc_mountpoint.set_storage(storage);
|
||||
}
|
||||
|
||||
async _init () {
|
||||
|
32
packages/backend/src/services/MountpointService.js
Normal file
32
packages/backend/src/services/MountpointService.js
Normal file
@ -0,0 +1,32 @@
|
||||
// const Mountpoint = o => ({ ...o });
|
||||
|
||||
const BaseService = require("./BaseService");
|
||||
|
||||
/**
|
||||
* This will eventually be a service which manages the storage
|
||||
* backends for mountpoints.
|
||||
*
|
||||
* For the moment, this is a way to access the storage backend
|
||||
* in situations where ContextInitService isn't able to
|
||||
* initialize a context.
|
||||
*/
|
||||
class MountpointService extends BaseService {
|
||||
async _init () {
|
||||
// this.mountpoints_ = {};
|
||||
|
||||
// Temporary solution - we'll develop this incrementally
|
||||
this.storage_ = null;
|
||||
}
|
||||
|
||||
// Temporary solution - we'll develop this incrementally
|
||||
set_storage (storage) {
|
||||
this.storage_ = storage;
|
||||
}
|
||||
get_storage () {
|
||||
return this.storage_;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
MountpointService,
|
||||
};
|
Loading…
Reference in New Issue
Block a user