UNPKG

@sync-in/server

Version:

The secure, open-source platform for file storage, sharing, collaboration, and sync

64 lines (63 loc) 2.38 kB
/* * Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com> * This file is part of Sync-in | The open source file sync and share solution * See the LICENSE file for licensing details */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "SpaceModel", { enumerable: true, get: function() { return SpaceModel; } }); const _promises = /*#__PURE__*/ _interop_require_default(require("node:fs/promises")); const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path")); const _configenvironment = require("../../../configuration/config.environment"); const _spaces = require("../constants/spaces"); function _interop_require_default(obj) { return obj && obj.__esModule ? obj : { default: obj }; } let SpaceModel = class SpaceModel { get homePath() { return this._homePath ||= _nodepath.default.join(_configenvironment.configuration.applications.files.spacesPath, this.alias); } get filesPath() { return this._filesPath ||= _nodepath.default.join(this.homePath, _spaces.SPACE_REPOSITORY.FILES); } get trashPath() { return this._trashPath ||= _nodepath.default.join(this.homePath, _spaces.SPACE_REPOSITORY.TRASH); } static async makePaths(spaceAlias) { for (const p of [ SpaceModel.getFilesPath(spaceAlias), SpaceModel.getTrashPath(spaceAlias) ]){ await _promises.default.mkdir(p, { recursive: true }); } } static getHomePath(spaceAlias) { return _nodepath.default.join(_configenvironment.configuration.applications.files.spacesPath, spaceAlias); } static getFilesPath(spaceAlias) { return _nodepath.default.join(SpaceModel.getHomePath(spaceAlias), _spaces.SPACE_REPOSITORY.FILES); } static getTrashPath(spaceAlias) { return _nodepath.default.join(SpaceModel.getHomePath(spaceAlias), _spaces.SPACE_REPOSITORY.TRASH); } static getRepositoryPath(spaceAlias, inTrash = false) { if (inTrash) return SpaceModel.getTrashPath(spaceAlias); return SpaceModel.getFilesPath(spaceAlias); } constructor(props){ // outside db schema this.root = []; Object.assign(this, props); } }; //# sourceMappingURL=space.model.js.map