refactor(backends): cleanup code

This commit is contained in:
Nicolas Meienberger
2025-11-20 06:36:47 +01:00
parent b70f973c12
commit 3c2791102f
19 changed files with 295 additions and 544 deletions

View File

@@ -52,12 +52,18 @@ const checkHealth = async (config: BackendConfig) => {
}
};
export const makeDirectoryBackend = (config: BackendConfig, volumeName: string, volumePath: string): VolumeBackend => ({
const getVolumePath = (config: BackendConfig): string => {
if (config.backend !== "directory") {
throw new Error("Invalid backend type");
}
return config.path;
};
export const makeDirectoryBackend = (config: BackendConfig, volumePath: string): VolumeBackend => ({
mount: () => mount(config, volumePath),
unmount,
checkHealth: () => checkHealth(config),
getVolumePath: () => config.backend === "directory" ? config.path : volumePath,
isDatabaseBackend: () => false,
getDumpPath: () => null,
getDumpFilePath: () => null,
getVolumePath: () => getVolumePath(config),
getBackupPath: async () => getVolumePath(config),
});