zerobyte/app/server/jobs/auto-remount.ts
Nico 332e5bffda
refactor: extract restic in core package (#651)
* refactor: extract restic in core package

* chore: add turbo task runner

* refactor: split server utils

* chore: simplify withDeps signature and fix non-null assertion
2026-03-11 21:56:07 +01:00

29 lines
846 B
TypeScript

import { Job } from "../core/scheduler";
import { volumeService } from "../modules/volumes/volume.service";
import { logger } from "@zerobyte/core/node";
import { db } from "../db/db";
import { withContext } from "../core/request-context";
export class VolumeAutoRemountJob extends Job {
async run() {
logger.debug("Running auto-remount for all errored volumes...");
const volumes = await db.query.volumesTable.findMany({
where: { status: "error" },
});
for (const volume of volumes) {
if (volume.autoRemount) {
try {
await withContext({ organizationId: volume.organizationId }, async () => {
await volumeService.mountVolume(volume.shortId);
});
} catch (err) {
logger.error(`Failed to auto-remount volume ${volume.name}:`, err);
}
}
}
return { done: true, timestamp: new Date() };
}
}