mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: use getVolumePath helper
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { BackendStatus } from "@ironmount/schemas";
|
||||
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
||||
import type { Volume } from "../../db/schema";
|
||||
import { getVolumePath } from "../volumes/helpers";
|
||||
import { makeDirectoryBackend } from "./directory/directory-backend";
|
||||
import { makeNfsBackend } from "./nfs/nfs-backend";
|
||||
import { makeSmbBackend } from "./smb/smb-backend";
|
||||
@@ -18,7 +18,7 @@ export type VolumeBackend = {
|
||||
};
|
||||
|
||||
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
||||
const path = `${VOLUME_MOUNT_BASE}/${volume.name}/_data`;
|
||||
const path = getVolumePath(volume.name);
|
||||
|
||||
switch (volume.config.backend) {
|
||||
case "nfs": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Hono } from "hono";
|
||||
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
||||
import { volumeService } from "../volumes/volume.service";
|
||||
import { getVolumePath } from "../volumes/helpers";
|
||||
|
||||
export const driverController = new Hono()
|
||||
.post("/VolumeDriver.Capabilities", (c) => {
|
||||
@@ -32,10 +32,8 @@ export const driverController = new Hono()
|
||||
|
||||
const volumeName = body.Name.replace(/^im-/, "");
|
||||
|
||||
const mountpoint = `${VOLUME_MOUNT_BASE}/${volumeName}/_data`;
|
||||
|
||||
return c.json({
|
||||
Mountpoint: mountpoint,
|
||||
Mountpoint: getVolumePath(volumeName),
|
||||
});
|
||||
})
|
||||
.post("/VolumeDriver.Unmount", (c) => {
|
||||
@@ -53,7 +51,7 @@ export const driverController = new Hono()
|
||||
const { volume } = await volumeService.getVolume(body.Name.replace(/^im-/, ""));
|
||||
|
||||
return c.json({
|
||||
Mountpoint: `${VOLUME_MOUNT_BASE}/${volume.name}/_data`,
|
||||
Mountpoint: getVolumePath(volume.name),
|
||||
});
|
||||
})
|
||||
.post("/VolumeDriver.Get", async (c) => {
|
||||
@@ -68,7 +66,7 @@ export const driverController = new Hono()
|
||||
return c.json({
|
||||
Volume: {
|
||||
Name: `im-${volume.name}`,
|
||||
Mountpoint: `${VOLUME_MOUNT_BASE}/${volume.name}/_data`,
|
||||
Mountpoint: getVolumePath(volume.name),
|
||||
Status: {},
|
||||
},
|
||||
Err: "",
|
||||
@@ -79,7 +77,7 @@ export const driverController = new Hono()
|
||||
|
||||
const res = volumes.map((volume) => ({
|
||||
Name: `im-${volume.name}`,
|
||||
Mountpoint: `${VOLUME_MOUNT_BASE}/${volume.name}/_data`,
|
||||
Mountpoint: getVolumePath(volume.name),
|
||||
Status: {},
|
||||
}));
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ const getVolume = async (name: string) => {
|
||||
|
||||
let statfs: Partial<StatFs> = {};
|
||||
if (volume.status === "mounted") {
|
||||
statfs = await getStatFs(`${VOLUME_MOUNT_BASE}/${name}/_data`).catch(() => ({}));
|
||||
statfs = await getStatFs(getVolumePath(name)).catch(() => ({}));
|
||||
}
|
||||
|
||||
return { volume, statfs };
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"enabled": true,
|
||||
"actions": {
|
||||
"source": {
|
||||
"organizeImports": "on"
|
||||
"organizeImports": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user