From 1beee3ac103c7ba697a920b2ce60f168366e9ee4 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Sun, 13 Aug 2023 01:46:18 -0700 Subject: [PATCH] chore: prevent access to pb_data and pb_migrations while instance may be running --- .../daemon/src/services/FtpService/PhFs.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/daemon/src/services/FtpService/PhFs.ts b/packages/daemon/src/services/FtpService/PhFs.ts index 507f59c1..b7b0919c 100644 --- a/packages/daemon/src/services/FtpService/PhFs.ts +++ b/packages/daemon/src/services/FtpService/PhFs.ts @@ -14,7 +14,12 @@ import { customAlphabet } from 'nanoid' import { isAbsolute, join, normalize, resolve, sep } from 'path' import { PocketbaseClientApi } from '../clientService/PbClient' import * as fsAsync from './fs-async' -import { INSTANCE_ROOT_FOLDER_NAMES, isInstanceRootFolder } from './FtpService' +import { + FolderNames, + INSTANCE_ROOT_FOLDER_NAMES, + isInstanceRootFolder, + MAINTENANCE_ONLY_FOLDER_NAMES, +} from './FtpService' const nanoid = customAlphabet(`abcdefghijklmnop`) @@ -100,6 +105,17 @@ export class PhFs implements FileSystem { } fsPathParts.push(instance.id) if (rootFolderName) { + dbg({ rootFolderName, instance }) + if ( + MAINTENANCE_ONLY_FOLDER_NAMES.includes( + rootFolderName as FolderNames + ) && + !instance.maintenance + ) { + throw new Error( + `Instance must be in maintenance mode to access ${rootFolderName}` + ) + } fsPathParts.push(rootFolderName) // Ensure folder exists const rootFolderFsPath = resolve(