feat(restore): delete files not in snapshot option

This commit is contained in:
Nicolas Meienberger
2025-11-05 19:00:44 +01:00
parent ab997ef450
commit 99d4d46338
6 changed files with 33 additions and 7 deletions

View File

@@ -111,9 +111,9 @@ export const repositoriesController = new Hono()
)
.post("/:name/restore", restoreSnapshotDto, validator("json", restoreSnapshotBody), async (c) => {
const { name } = c.req.param();
const { snapshotId, include, exclude } = c.req.valid("json");
const { snapshotId, ...options } = c.req.valid("json");
const result = await repositoriesService.restoreSnapshot(name, snapshotId, { include, exclude });
const result = await repositoriesService.restoreSnapshot(name, snapshotId, options);
return c.json<RestoreSnapshotDto>(result, 200);
});

View File

@@ -242,6 +242,7 @@ export const restoreSnapshotBody = type({
snapshotId: "string",
include: "string[]?",
exclude: "string[]?",
delete: "boolean?",
});
export type RestoreSnapshotBody = typeof restoreSnapshotBody.infer;

View File

@@ -163,7 +163,7 @@ const listSnapshotFiles = async (name: string, snapshotId: string, path?: string
const restoreSnapshot = async (
name: string,
snapshotId: string,
options?: { include?: string[]; exclude?: string[] },
options?: { include?: string[]; exclude?: string[]; delete?: boolean },
) => {
const repository = await db.query.repositoriesTable.findFirst({
where: eq(repositoriesTable.name, name),