mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
new abstract method for volumepath
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { BackendStatus } from "~/schemas/volumes";
|
||||
import type { Volume } from "../../db/schema";
|
||||
import { getVolumePath } from "../volumes/helpers";
|
||||
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
||||
import { makeDirectoryBackend } from "./directory/directory-backend";
|
||||
import { makeNfsBackend } from "./nfs/nfs-backend";
|
||||
import { makeSmbBackend } from "./smb/smb-backend";
|
||||
@@ -18,32 +18,38 @@ export type VolumeBackend = {
|
||||
mount: () => Promise<OperationResult>;
|
||||
unmount: () => Promise<OperationResult>;
|
||||
checkHealth: () => Promise<OperationResult>;
|
||||
getVolumePath: () => string;
|
||||
isDatabaseBackend: () => boolean;
|
||||
getDumpPath: () => string | null;
|
||||
getDumpFilePath: (timestamp: number) => string | null;
|
||||
};
|
||||
|
||||
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
||||
const path = getVolumePath(volume);
|
||||
const path = volume.config.backend === "directory"
|
||||
? volume.config.path
|
||||
: `${VOLUME_MOUNT_BASE}/${volume.name}/_data`;
|
||||
|
||||
switch (volume.config.backend) {
|
||||
case "nfs": {
|
||||
return makeNfsBackend(volume.config, path);
|
||||
return makeNfsBackend(volume.config, volume.name, path);
|
||||
}
|
||||
case "smb": {
|
||||
return makeSmbBackend(volume.config, path);
|
||||
return makeSmbBackend(volume.config, volume.name, path);
|
||||
}
|
||||
case "directory": {
|
||||
return makeDirectoryBackend(volume.config, path);
|
||||
return makeDirectoryBackend(volume.config, volume.name, path);
|
||||
}
|
||||
case "webdav": {
|
||||
return makeWebdavBackend(volume.config, path);
|
||||
return makeWebdavBackend(volume.config, volume.name, path);
|
||||
}
|
||||
case "mariadb": {
|
||||
return makeMariaDBBackend(volume.config, path);
|
||||
return makeMariaDBBackend(volume.config, volume.name, path);
|
||||
}
|
||||
case "mysql": {
|
||||
return makeMySQLBackend(volume.config, path);
|
||||
return makeMySQLBackend(volume.config, volume.name, path);
|
||||
}
|
||||
case "postgres": {
|
||||
return makePostgresBackend(volume.config, path);
|
||||
return makePostgresBackend(volume.config, volume.name, path);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported backend type: ${(volume.config as any).backend}`);
|
||||
|
||||
Reference in New Issue
Block a user