From e98ff552d144a14657e68eb1a7ca17ab85225f3e Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Sun, 7 Jul 2024 00:58:46 -0400 Subject: [PATCH] dev: begin mountpoints --- .../backend/src/filesystem/backends/Test.js | 24 ------------------- .../backend/src/filesystem/backends/Test.ts | 3 --- .../filesystem_a/LocalFilesystem.js | 7 ++++++ .../filesystem_a/PuterFilesystem.js | 0 .../strategies/filesystem_a/brainstorming.md | 14 +++++++++++ .../backend/src/services/MountpointService.js | 23 ++++++++++++++++++ 6 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 packages/backend/src/filesystem/backends/Test.js delete mode 100644 packages/backend/src/filesystem/backends/Test.ts create mode 100644 packages/backend/src/filesystem/strategies/filesystem_a/LocalFilesystem.js create mode 100644 packages/backend/src/filesystem/strategies/filesystem_a/PuterFilesystem.js create mode 100644 packages/backend/src/filesystem/strategies/filesystem_a/brainstorming.md diff --git a/packages/backend/src/filesystem/backends/Test.js b/packages/backend/src/filesystem/backends/Test.js deleted file mode 100644 index d2f35d62..00000000 --- a/packages/backend/src/filesystem/backends/Test.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2024 Puter Technologies Inc. - * - * This file is part of Puter. - * - * Puter is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Test = void 0; -class Test { -} -exports.Test = Test; diff --git a/packages/backend/src/filesystem/backends/Test.ts b/packages/backend/src/filesystem/backends/Test.ts deleted file mode 100644 index 6b8585ca..00000000 --- a/packages/backend/src/filesystem/backends/Test.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class Test { - // -} \ No newline at end of file diff --git a/packages/backend/src/filesystem/strategies/filesystem_a/LocalFilesystem.js b/packages/backend/src/filesystem/strategies/filesystem_a/LocalFilesystem.js new file mode 100644 index 00000000..0f1936d2 --- /dev/null +++ b/packages/backend/src/filesystem/strategies/filesystem_a/LocalFilesystem.js @@ -0,0 +1,7 @@ +const { AdvancedBase } = require("@heyputer/puter-js-common"); + +class LocalFilesystem extends AdvancedBase { + async _init () { + this.root_ = this.config.path; + } +} diff --git a/packages/backend/src/filesystem/strategies/filesystem_a/PuterFilesystem.js b/packages/backend/src/filesystem/strategies/filesystem_a/PuterFilesystem.js new file mode 100644 index 00000000..e69de29b diff --git a/packages/backend/src/filesystem/strategies/filesystem_a/brainstorming.md b/packages/backend/src/filesystem/strategies/filesystem_a/brainstorming.md new file mode 100644 index 00000000..8da528a1 --- /dev/null +++ b/packages/backend/src/filesystem/strategies/filesystem_a/brainstorming.md @@ -0,0 +1,14 @@ +### implementations needed +- stat a file from fsentry row or inode +- get a read stream for a file +- +```mermaid +classDiagram + API ..> HLOperation + HLOperation ..> LLOperation + LLOperation ..> LLFilesystem + LLFilesystem <|-- PuterFS + LLFilesystem <|-- LocalFS + PuterFS o--> Storage + PuterFS o--> FSEntryService +``` diff --git a/packages/backend/src/services/MountpointService.js b/packages/backend/src/services/MountpointService.js index a8a24b5b..bfb33c6f 100644 --- a/packages/backend/src/services/MountpointService.js +++ b/packages/backend/src/services/MountpointService.js @@ -11,11 +11,34 @@ const BaseService = require("./BaseService"); * initialize a context. */ class MountpointService extends BaseService { + static default_mountpoints = [ + { + mapping: '/', + engine: 'puter', + }, + { + mapping: '/x/mnt/local', + engine: 'local', + parameters: { + auto_mkdir: true, + path: '{runtime}/local', + uid_strategy: 'uuidv4', + } + } + ] + async _init () { // this.mountpoints_ = {}; // Temporary solution - we'll develop this incrementally this.storage_ = null; + this.mounts_ = {}; + + const mountpoints = [ + ...this.constructor.default_mountpoints, + ...(this.config.mountpoints ?? []) + ]; + // } // Temporary solution - we'll develop this incrementally