mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: add webdav support
This commit is contained in:
@@ -55,13 +55,17 @@ export const volumeController = new Hono()
|
||||
const res = await volumeService.getVolume(name);
|
||||
|
||||
const response = {
|
||||
...res,
|
||||
volume: {
|
||||
...res.volume,
|
||||
createdAt: res.volume.createdAt.getTime(),
|
||||
updatedAt: res.volume.updatedAt.getTime(),
|
||||
lastHealthCheck: res.volume.lastHealthCheck.getTime(),
|
||||
},
|
||||
statfs: {
|
||||
total: res.statfs.total ?? 0,
|
||||
used: res.statfs.used ?? 0,
|
||||
free: res.statfs.free ?? 0,
|
||||
},
|
||||
} satisfies GetVolumeResponseDto;
|
||||
|
||||
return c.json(response, 200);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { resolver } from "hono-openapi/arktype";
|
||||
const volumeSchema = type({
|
||||
name: "string",
|
||||
path: "string",
|
||||
type: type.enumerated("nfs", "smb", "directory"),
|
||||
type: type.enumerated("nfs", "smb", "directory", "webdav"),
|
||||
status: type.enumerated("mounted", "unmounted", "error", "unknown"),
|
||||
lastError: "string | null",
|
||||
createdAt: "number",
|
||||
@@ -100,13 +100,15 @@ export const deleteVolumeDto = describeRoute({
|
||||
},
|
||||
});
|
||||
|
||||
const statfsSchema = type({
|
||||
total: "number",
|
||||
used: "number",
|
||||
free: "number",
|
||||
});
|
||||
|
||||
const getVolumeResponse = type({
|
||||
volume: volumeSchema,
|
||||
statfs: type({
|
||||
total: "number = 0",
|
||||
used: "number = 0",
|
||||
free: "number = 0",
|
||||
}),
|
||||
statfs: statfsSchema,
|
||||
});
|
||||
|
||||
export type GetVolumeResponseDto = typeof getVolumeResponse.infer;
|
||||
|
||||
@@ -12,6 +12,7 @@ import { createVolumeBackend } from "../backends/backend";
|
||||
import { toMessage } from "../../utils/errors";
|
||||
import { getStatFs, type StatFs } from "../../utils/mountinfo";
|
||||
import { VOLUME_MOUNT_BASE } from "../../core/constants";
|
||||
import { logger } from "../../utils/logger";
|
||||
|
||||
const listVolumes = async () => {
|
||||
const volumes = await db.query.volumesTable.findMany({});
|
||||
@@ -73,7 +74,7 @@ const mountVolume = async (name: string) => {
|
||||
|
||||
await db
|
||||
.update(volumesTable)
|
||||
.set({ status, lastError: error, lastHealthCheck: new Date() })
|
||||
.set({ status, lastError: error ?? null, lastHealthCheck: new Date() })
|
||||
.where(eq(volumesTable.name, name));
|
||||
|
||||
return { error, status };
|
||||
|
||||
Reference in New Issue
Block a user