diff --git a/app/client/modules/repositories/components/compression-stats-chart.tsx b/app/client/modules/repositories/components/compression-stats-chart.tsx index 65043119..74996c78 100644 --- a/app/client/modules/repositories/components/compression-stats-chart.tsx +++ b/app/client/modules/repositories/components/compression-stats-chart.tsx @@ -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) { Stored Size
- +
@@ -91,7 +91,7 @@ export function CompressionStatsChart({ repositoryShortId }: Props) { Uncompressed
- +
@@ -101,7 +101,7 @@ export function CompressionStatsChart({ repositoryShortId }: Props) {
{spaceSavingPercent.toFixed(1)}% - +
diff --git a/app/server/modules/repositories/__tests__/repositories.service.test.ts b/app/server/modules/repositories/__tests__/repositories.service.test.ts index 079884ba..456414b3 100644 --- a/app/server/modules/repositories/__tests__/repositories.service.test.ts +++ b/app/server/modules/repositories/__tests__/repositories.service.test.ts @@ -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`), ), diff --git a/app/server/utils/cache.ts b/app/server/utils/cache.ts index ac8f56c6..7af4e0e1 100644 --- a/app/server/utils/cache.ts +++ b/app/server/utils/cache.ts @@ -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 = (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 }[] = []; diff --git a/app/server/utils/restic.ts b/app/server/utils/restic.ts index 0221f853..ada00097 100644 --- a/app/server/utils/restic.ts +++ b/app/server/utils/restic.ts @@ -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;