mirror of
https://github.com/nicotsx/zerobyte.git
synced 2025-12-10 12:10:51 +01:00
25 lines
618 B
TypeScript
25 lines
618 B
TypeScript
import type { Volume } from "../../db/schema";
|
|
import { makeDirectoryBackend } from "./directory/directory-backend";
|
|
import { makeNfsBackend } from "./nfs/nfs-backend";
|
|
|
|
export type VolumeBackend = {
|
|
mount: () => Promise<void>;
|
|
unmount: () => Promise<void>;
|
|
};
|
|
|
|
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
|
const { config, path } = volume;
|
|
|
|
switch (config.backend) {
|
|
case "nfs": {
|
|
return makeNfsBackend(config, path);
|
|
}
|
|
case "directory": {
|
|
return makeDirectoryBackend(config, path);
|
|
}
|
|
default: {
|
|
throw new Error(`Backend ${config.backend} not implemented`);
|
|
}
|
|
}
|
|
};
|