chore: PR feedbacks

This commit is contained in:
Nicolas Meienberger 2026-02-10 20:12:13 +01:00
parent 78d16fc403
commit 2651407beb
4 changed files with 11 additions and 10 deletions

View file

@ -14,7 +14,7 @@ import { restic } from "~/server/utils/restic";
import { NotFoundError, BadRequestError } from "http-errors-enhanced";
const resticBackupMock = mock(() => Promise.resolve({ exitCode: 0, summary: generateBackupOutput(), error: "" }));
const resticForgetMock = mock(() => Promise.resolve({ success: true }));
const resticForgetMock = mock(() => Promise.resolve({ success: true, data: null }));
const resticCopyMock = mock(() => Promise.resolve({ success: true, output: "" }));
beforeEach(() => {

View file

@ -15,7 +15,7 @@ const backupMock = mock(() => Promise.resolve({ exitCode: 0, result: JSON.parse(
beforeEach(() => {
backupMock.mockClear();
spyOn(restic, "backup").mockImplementation(backupMock);
spyOn(restic, "forget").mockImplementation(mock(() => Promise.resolve({ success: true })));
spyOn(restic, "forget").mockImplementation(mock(() => Promise.resolve({ success: true, data: null })));
spyOn(context, "getOrganizationId").mockReturnValue(TEST_ORG_ID);
});

View file

@ -629,7 +629,7 @@ const getRetentionCategories = async (repositoryId: string, scheduleId?: string)
}
const categories = parseRetentionCategories(dryRunResults.data);
cache.set(cacheKey, categories);
cache.set(cacheKey, Object.fromEntries(categories));
return categories;
} catch (error) {

View file

@ -13,6 +13,7 @@ import { safeSpawn, exec } from "./spawn";
import type { CompressionMode, RepositoryConfig, OverwriteMode, BandwidthLimit } from "~/schemas/restic";
import { ResticError } from "./errors";
import { db } from "../db/db";
import { safeJsonParse } from "./json";
const backupOutputSchema = type({
message_type: "'summary'",
@ -565,17 +566,17 @@ export interface ForgetGroup {
export interface Snapshot {
time: string;
parent: string;
parent?: string;
tree: string;
paths: string[];
hostname: string;
username: string;
uid: number;
gid: number;
username?: string;
uid?: number;
gid?: number;
excludes?: string[] | null;
tags?: string[] | null;
program_version: string;
summary: SnapshotSummary;
program_version?: string;
summary?: SnapshotSummary;
id: string;
short_id: string;
}
@ -653,7 +654,7 @@ const forget = async (
}
const lines = res.stdout.split("\n").filter((line) => line.trim());
const result = extra.dryRun ? (JSON.parse(lines.at(-1) ?? "[]") as ResticForgetResponse) : null;
const result = extra.dryRun ? safeJsonParse<ResticForgetResponse>(lines.at(-1) ?? "[]") : null;
return { success: true, data: result };
};