mirror of
https://github.com/nicotsx/zerobyte.git
synced 2025-12-10 12:10:51 +01:00
fix: get correct volume path for directories
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
||||
import type { Volume } from "../../db/schema";
|
||||
|
||||
export const getVolumePath = (name: string) => {
|
||||
return `${VOLUME_MOUNT_BASE}/${name}/_data`;
|
||||
export const getVolumePath = (volume: Volume) => {
|
||||
if (volume.config.backend === "directory") {
|
||||
return volume.config.path;
|
||||
}
|
||||
|
||||
return `${VOLUME_MOUNT_BASE}/${volume.name}/_data`;
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ export const volumeController = new Hono()
|
||||
|
||||
const response = {
|
||||
...res.volume,
|
||||
path: getVolumePath(res.volume.name),
|
||||
path: getVolumePath(res.volume),
|
||||
};
|
||||
|
||||
return c.json<CreateVolumeDto>(response, 201);
|
||||
@@ -63,7 +63,7 @@ export const volumeController = new Hono()
|
||||
const response = {
|
||||
volume: {
|
||||
...res.volume,
|
||||
path: getVolumePath(res.volume.name),
|
||||
path: getVolumePath(res.volume),
|
||||
},
|
||||
statfs: {
|
||||
total: res.statfs.total ?? 0,
|
||||
@@ -87,7 +87,7 @@ export const volumeController = new Hono()
|
||||
|
||||
const response = {
|
||||
...res.volume,
|
||||
path: getVolumePath(res.volume.name),
|
||||
path: getVolumePath(res.volume),
|
||||
};
|
||||
|
||||
return c.json<UpdateVolumeDto>(response, 200);
|
||||
|
||||
@@ -128,7 +128,7 @@ const getVolume = async (name: string) => {
|
||||
|
||||
let statfs: Partial<StatFs> = {};
|
||||
if (volume.status === "mounted") {
|
||||
statfs = await getStatFs(getVolumePath(name)).catch(() => ({}));
|
||||
statfs = await getStatFs(getVolumePath(volume)).catch(() => ({}));
|
||||
}
|
||||
|
||||
return { volume, statfs };
|
||||
@@ -292,7 +292,7 @@ const listFiles = async (name: string, subPath?: string) => {
|
||||
}
|
||||
|
||||
// For directory volumes, use the configured path directly
|
||||
const volumePath = volume.config.backend === "directory" ? volume.config.path : getVolumePath(volume.name);
|
||||
const volumePath = getVolumePath(volume);
|
||||
|
||||
const requestedPath = subPath ? path.join(volumePath, subPath) : volumePath;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user