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) {