From beda5a4008841f22309c743cf6b558dc25b1fe12 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Mon, 29 Dec 2025 18:13:53 +0100 Subject: [PATCH] chore: pr feedbacks --- app/server/modules/repositories/repositories.dto.ts | 4 ++-- app/server/utils/restic.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/server/modules/repositories/repositories.dto.ts b/app/server/modules/repositories/repositories.dto.ts index 4c00f30f..56a215e3 100644 --- a/app/server/modules/repositories/repositories.dto.ts +++ b/app/server/modules/repositories/repositories.dto.ts @@ -405,7 +405,7 @@ export const deleteSnapshotDto = describeRoute({ * Delete multiple snapshots */ export const deleteSnapshotsBody = type({ - snapshotIds: "string[]", + snapshotIds: "string[]>=1", }); export const deleteSnapshotsResponse = type({ @@ -434,7 +434,7 @@ export const deleteSnapshotsDto = describeRoute({ * Tag multiple snapshots */ export const tagSnapshotsBody = type({ - snapshotIds: "string[]", + snapshotIds: "string[]>=1", add: "string[]?", remove: "string[]?", set: "string[]?", diff --git a/app/server/utils/restic.ts b/app/server/utils/restic.ts index a2acc52a..a4880431 100644 --- a/app/server/utils/restic.ts +++ b/app/server/utils/restic.ts @@ -571,6 +571,10 @@ const deleteSnapshots = async (config: RepositoryConfig, snapshotIds: string[]) const repoUrl = buildRepoUrl(config); const env = await buildEnv(config); + if (snapshotIds.length === 0) { + throw new Error("No snapshot IDs provided for deletion."); + } + const args: string[] = ["--repo", repoUrl, "forget", ...snapshotIds, "--prune"]; addCommonArgs(args, env); @@ -597,6 +601,10 @@ const tagSnapshots = async ( const repoUrl = buildRepoUrl(config); const env = await buildEnv(config); + if (snapshotIds.length === 0) { + throw new Error("No snapshot IDs provided for tagging."); + } + const args: string[] = ["--repo", repoUrl, "tag", ...snapshotIds]; if (tags.add) {