new abstract method for volumepath

This commit is contained in:
Renan Bernordi
2025-11-16 17:47:23 -03:00
parent ff16c6914d
commit 14dadc85e7
14 changed files with 112 additions and 84 deletions

View File

@@ -3,7 +3,7 @@ import path from "node:path";
import fs from "node:fs/promises";
import { volumeService } from "../modules/volumes/volume.service";
import { readMountInfo } from "../utils/mountinfo";
import { getVolumePath } from "../modules/volumes/helpers";
import { createVolumeBackend } from "../modules/backends/backend";
import { logger } from "../utils/logger";
import { executeUnmount } from "../modules/backends/utils/backend-utils";
import { toMessage } from "../utils/errors";
@@ -16,7 +16,10 @@ export class CleanupDanglingMountsJob extends Job {
for (const mount of allSystemMounts) {
if (mount.mountPoint.includes("ironmount") && mount.mountPoint.endsWith("_data")) {
const matchingVolume = allVolumes.find((v) => getVolumePath(v) === mount.mountPoint);
const matchingVolume = allVolumes.find((v) => {
const backend = createVolumeBackend(v);
return backend.getVolumePath() === mount.mountPoint;
});
if (!matchingVolume) {
logger.info(`Found dangling mount at ${mount.mountPoint}, attempting to unmount...`);
await executeUnmount(mount.mountPoint).catch((err) => {
@@ -36,7 +39,10 @@ export class CleanupDanglingMountsJob extends Job {
for (const dir of allIronmountDirs) {
const volumePath = `${VOLUME_MOUNT_BASE}/${dir}/_data`;
const matchingVolume = allVolumes.find((v) => getVolumePath(v) === volumePath);
const matchingVolume = allVolumes.find((v) => {
const backend = createVolumeBackend(v);
return backend.getVolumePath() === volumePath;
});
if (!matchingVolume) {
const fullPath = path.join(VOLUME_MOUNT_BASE, dir);
logger.info(`Found dangling mount directory at ${fullPath}, attempting to remove...`);