mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
fix: get correct volume path for directories
This commit is contained in:
@@ -38,7 +38,7 @@ In order to run Ironmount, you need to have Docker and Docker Compose installed
|
|||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
ironmount:
|
ironmount:
|
||||||
image: ghcr.io/nicotsx/ironmount:v0.4.0
|
image: ghcr.io/nicotsx/ironmount:v0.5.0
|
||||||
container_name: ironmount
|
container_name: ironmount
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
privileged: true
|
privileged: true
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class CleanupDanglingMountsJob extends Job {
|
|||||||
|
|
||||||
for (const mount of allSystemMounts) {
|
for (const mount of allSystemMounts) {
|
||||||
if (mount.mountPoint.includes("ironmount") && mount.mountPoint.endsWith("_data")) {
|
if (mount.mountPoint.includes("ironmount") && mount.mountPoint.endsWith("_data")) {
|
||||||
const matchingVolume = allVolumes.find((v) => getVolumePath(v.name) === mount.mountPoint);
|
const matchingVolume = allVolumes.find((v) => getVolumePath(v) === mount.mountPoint);
|
||||||
if (!matchingVolume) {
|
if (!matchingVolume) {
|
||||||
logger.info(`Found dangling mount at ${mount.mountPoint}, attempting to unmount...`);
|
logger.info(`Found dangling mount at ${mount.mountPoint}, attempting to unmount...`);
|
||||||
await executeUnmount(mount.mountPoint);
|
await executeUnmount(mount.mountPoint);
|
||||||
@@ -33,8 +33,8 @@ export class CleanupDanglingMountsJob extends Job {
|
|||||||
const allIronmountDirs = await fs.readdir(VOLUME_MOUNT_BASE).catch(() => []);
|
const allIronmountDirs = await fs.readdir(VOLUME_MOUNT_BASE).catch(() => []);
|
||||||
|
|
||||||
for (const dir of allIronmountDirs) {
|
for (const dir of allIronmountDirs) {
|
||||||
const volumePath = getVolumePath(dir);
|
const volumePath = `${VOLUME_MOUNT_BASE}/${dir}/_data`;
|
||||||
const matchingVolume = allVolumes.find((v) => getVolumePath(v.name) === volumePath);
|
const matchingVolume = allVolumes.find((v) => getVolumePath(v) === volumePath);
|
||||||
if (!matchingVolume) {
|
if (!matchingVolume) {
|
||||||
const fullPath = path.join(VOLUME_MOUNT_BASE, dir);
|
const fullPath = path.join(VOLUME_MOUNT_BASE, dir);
|
||||||
logger.info(`Found dangling mount directory at ${fullPath}, attempting to remove...`);
|
logger.info(`Found dangling mount directory at ${fullPath}, attempting to remove...`);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export type VolumeBackend = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
||||||
const path = getVolumePath(volume.name);
|
const path = getVolumePath(volume);
|
||||||
|
|
||||||
switch (volume.config.backend) {
|
switch (volume.config.backend) {
|
||||||
case "nfs": {
|
case "nfs": {
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ const executeBackup = async (scheduleId: number, manual = false) => {
|
|||||||
.where(eq(backupSchedulesTable.id, scheduleId));
|
.where(eq(backupSchedulesTable.id, scheduleId));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const volumePath = getVolumePath(volume.name);
|
const volumePath = getVolumePath(volume);
|
||||||
|
|
||||||
const backupOptions: {
|
const backupOptions: {
|
||||||
exclude?: string[];
|
exclude?: string[];
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const driverController = new Hono()
|
|||||||
const { volume } = await volumeService.getVolume(body.Name.replace(/^im-/, ""));
|
const { volume } = await volumeService.getVolume(body.Name.replace(/^im-/, ""));
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
Mountpoint: getVolumePath(volume.name),
|
Mountpoint: getVolumePath(volume),
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.post("/VolumeDriver.Get", async (c) => {
|
.post("/VolumeDriver.Get", async (c) => {
|
||||||
@@ -66,7 +66,7 @@ export const driverController = new Hono()
|
|||||||
return c.json({
|
return c.json({
|
||||||
Volume: {
|
Volume: {
|
||||||
Name: `im-${volume.name}`,
|
Name: `im-${volume.name}`,
|
||||||
Mountpoint: getVolumePath(volume.name),
|
Mountpoint: getVolumePath(volume),
|
||||||
Status: {},
|
Status: {},
|
||||||
},
|
},
|
||||||
Err: "",
|
Err: "",
|
||||||
@@ -77,7 +77,7 @@ export const driverController = new Hono()
|
|||||||
|
|
||||||
const res = volumes.map((volume) => ({
|
const res = volumes.map((volume) => ({
|
||||||
Name: `im-${volume.name}`,
|
Name: `im-${volume.name}`,
|
||||||
Mountpoint: getVolumePath(volume.name),
|
Mountpoint: getVolumePath(volume),
|
||||||
Status: {},
|
Status: {},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
||||||
|
import type { Volume } from "../../db/schema";
|
||||||
|
|
||||||
export const getVolumePath = (name: string) => {
|
export const getVolumePath = (volume: Volume) => {
|
||||||
return `${VOLUME_MOUNT_BASE}/${name}/_data`;
|
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 = {
|
const response = {
|
||||||
...res.volume,
|
...res.volume,
|
||||||
path: getVolumePath(res.volume.name),
|
path: getVolumePath(res.volume),
|
||||||
};
|
};
|
||||||
|
|
||||||
return c.json<CreateVolumeDto>(response, 201);
|
return c.json<CreateVolumeDto>(response, 201);
|
||||||
@@ -63,7 +63,7 @@ export const volumeController = new Hono()
|
|||||||
const response = {
|
const response = {
|
||||||
volume: {
|
volume: {
|
||||||
...res.volume,
|
...res.volume,
|
||||||
path: getVolumePath(res.volume.name),
|
path: getVolumePath(res.volume),
|
||||||
},
|
},
|
||||||
statfs: {
|
statfs: {
|
||||||
total: res.statfs.total ?? 0,
|
total: res.statfs.total ?? 0,
|
||||||
@@ -87,7 +87,7 @@ export const volumeController = new Hono()
|
|||||||
|
|
||||||
const response = {
|
const response = {
|
||||||
...res.volume,
|
...res.volume,
|
||||||
path: getVolumePath(res.volume.name),
|
path: getVolumePath(res.volume),
|
||||||
};
|
};
|
||||||
|
|
||||||
return c.json<UpdateVolumeDto>(response, 200);
|
return c.json<UpdateVolumeDto>(response, 200);
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ const getVolume = async (name: string) => {
|
|||||||
|
|
||||||
let statfs: Partial<StatFs> = {};
|
let statfs: Partial<StatFs> = {};
|
||||||
if (volume.status === "mounted") {
|
if (volume.status === "mounted") {
|
||||||
statfs = await getStatFs(getVolumePath(name)).catch(() => ({}));
|
statfs = await getStatFs(getVolumePath(volume)).catch(() => ({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { volume, statfs };
|
return { volume, statfs };
|
||||||
@@ -292,7 +292,7 @@ const listFiles = async (name: string, subPath?: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For directory volumes, use the configured path directly
|
// 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;
|
const requestedPath = subPath ? path.join(volumePath, subPath) : volumePath;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user