Skip to content

Commit 9ad04cd

Browse files
committed
prereq: make it possible to access storage without context init
1 parent 332371f commit 9ad04cd

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

packages/backend/src/CoreModule.js

+3
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ const install = async ({ services, app, useapi }) => {
292292

293293
const { PermissionAPIService } = require('./services/PermissionAPIService');
294294
services.registerService('__permission-api', PermissionAPIService);
295+
296+
const { MountpointService } = require('./services/MountpointService');
297+
services.registerService('mountpoint', MountpointService);
295298
}
296299

297300
const install_legacy = async ({ services }) => {

packages/backend/src/filesystem/ll_operations/ll_write.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class LLWriteBase extends LLFilesystemOperation {
4949
const errors = svc.get('error-service').create(log);
5050
const svc_event = svc.get('event');
5151

52-
const storage = Context.get('storage');
52+
const svc_mountpoint = svc.get('mountpoint');
53+
const storage = svc_mountpoint.get_storage();
5354

5455
bucket ??= config.s3_bucket;
5556
bucket_region ??= config.s3_region;

packages/backend/src/helpers.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,9 @@ async function deleteUser(user_id){
10571057
for(let i=0; i<files.length; i++){
10581058
// init S3 SDK
10591059
const svc_fs = Context.get('services').get('filesystem');
1060-
const storage = Context.get('storage');
1060+
const svc_mountpoint =
1061+
Context.get('services').get('mountpoint');
1062+
const storage = svc_mountpoint.get_storage();
10611063
const op_delete = storage.create_delete();
10621064
await op_delete.run({
10631065
node: await svc_fs.node(new NodeUIDSelector(files[i].uuid))

packages/backend/src/services/LocalDiskStorageService.js

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class LocalDiskStorageService extends BaseService {
3131
const svc_contextInit = this.services.get('context-init');
3232
const storage = new LocalDiskStorageStrategy({ services: this.services });
3333
svc_contextInit.register_value('storage', storage);
34+
35+
const svc_mountpoint = this.services.get('mountpoint');
36+
svc_mountpoint.set_storage(storage);
3437
}
3538

3639
async _init () {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// const Mountpoint = o => ({ ...o });
2+
3+
const BaseService = require("./BaseService");
4+
5+
/**
6+
* This will eventually be a service which manages the storage
7+
* backends for mountpoints.
8+
*
9+
* For the moment, this is a way to access the storage backend
10+
* in situations where ContextInitService isn't able to
11+
* initialize a context.
12+
*/
13+
class MountpointService extends BaseService {
14+
async _init () {
15+
// this.mountpoints_ = {};
16+
17+
// Temporary solution - we'll develop this incrementally
18+
this.storage_ = null;
19+
}
20+
21+
// Temporary solution - we'll develop this incrementally
22+
set_storage (storage) {
23+
this.storage_ = storage;
24+
}
25+
get_storage () {
26+
return this.storage_;
27+
}
28+
}
29+
30+
module.exports = {
31+
MountpointService,
32+
};

0 commit comments

Comments
 (0)