chore: pr feedbacks

This commit is contained in:
Nicolas Meienberger 2026-02-21 10:38:31 +01:00
parent 438ea1c56d
commit 43b55623b2
4 changed files with 15 additions and 11 deletions

View file

@ -35,7 +35,7 @@ export function CompressionStatsChart({ repositoryShortId }: Props) {
const rawCompressionProgress = toSafeNumber(stats?.compression_progress);
const compressionProgressPercent = Math.min(100, Math.max(0, rawCompressionProgress));
const spaceSavingPercent = toSafeNumber(stats?.compression_space_saving) * 100;
const spaceSavingPercent = toSafeNumber(stats?.compression_space_saving);
const snapshotsCount = Math.round(toSafeNumber(stats?.snapshots_count));
const hasStats = !!stats && (storedSize > 0 || uncompressedSize > 0 || snapshotsCount > 0);
@ -82,7 +82,7 @@ export function CompressionStatsChart({ repositoryShortId }: Props) {
<span className="text-xs font-medium uppercase tracking-wider">Stored Size</span>
</div>
<div className="flex items-baseline gap-2">
<ByteSize bytes={storedSize} className="text-2xl font-bold font-mono text-foreground" />
<ByteSize base={1024} bytes={storedSize} className="text-2xl font-bold font-mono text-foreground" />
</div>
</div>
@ -91,7 +91,7 @@ export function CompressionStatsChart({ repositoryShortId }: Props) {
<span className="text-xs font-medium uppercase tracking-wider">Uncompressed</span>
</div>
<div className="flex items-baseline gap-2">
<ByteSize bytes={uncompressedSize} className="text-2xl font-bold font-mono text-foreground" />
<ByteSize base={1024} bytes={uncompressedSize} className="text-2xl font-bold font-mono text-foreground" />
</div>
</div>
@ -101,7 +101,7 @@ export function CompressionStatsChart({ repositoryShortId }: Props) {
</div>
<div className="flex items-baseline gap-2">
<span className="text-2xl font-bold font-mono text-foreground">{spaceSavingPercent.toFixed(1)}%</span>
<ByteSize bytes={savedSize} className="text-sm text-muted-foreground font-mono" base={1024} />
<ByteSize base={1024} bytes={savedSize} className="text-sm text-muted-foreground font-mono" />
</div>
</div>

View file

@ -244,7 +244,7 @@ describe("repositoriesService.dumpSnapshot", () => {
);
spyOn(restic, "snapshots").mockImplementation(snapshotsMock as typeof restic.snapshots);
await expect(
expect(
withContext({ organizationId, userId: user.id }, () =>
repositoriesService.dumpSnapshot(shortId, "snapshot-no-kind", `${basePath}/documents/report.txt`),
),

View file

@ -54,14 +54,20 @@ export const createCache = (options: CacheOptions = {}) => {
stmt.run(key);
};
const escapeLikePattern = (pattern: string): string => {
return pattern.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
};
const delByPrefix = (prefix: string) => {
const stmt = db.prepare("DELETE FROM cache WHERE key LIKE ?");
stmt.run(`${prefix}%`);
const escapedPrefix = escapeLikePattern(prefix);
const stmt = db.prepare("DELETE FROM cache WHERE key LIKE ? ESCAPE '\\'");
stmt.run(`${escapedPrefix}%`);
};
const getByPrefix = <T>(prefix: string): { key: string; value: T }[] => {
const stmt = db.prepare("SELECT key, value, expiration FROM cache WHERE key LIKE ?");
const rows = stmt.all(`${prefix}%`) as { key: string; value: string; expiration: number }[];
const escapedPrefix = escapeLikePattern(prefix);
const stmt = db.prepare("SELECT key, value, expiration FROM cache WHERE key LIKE ? ESCAPE '\\'");
const rows = stmt.all(`${escapedPrefix}%`) as { key: string; value: string; expiration: number }[];
const now = Date.now();
const results: { key: string; value: T }[] = [];

View file

@ -11,7 +11,6 @@ import {
type ResticBackupProgressDto,
type ResticRestoreOutputDto,
type ResticSnapshotSummaryDto,
type ResticStatsDto,
resticBackupOutputSchema,
resticBackupProgressSchema,
resticRestoreOutputSchema,
@ -417,7 +416,6 @@ const restoreProgressSchema = type({
});
export type RestoreProgress = typeof restoreProgressSchema.infer;
export type ResticStats = ResticStatsDto;
export interface ResticDumpStream {
stream: Readable;