feat(files): MAX_VERSIONS_KEPT statt zweier Konstanten

Die Zahl stand doppelt im Quelltext: als const im Backend und noch einmal
im Verlaufs-Dialog, verbunden nur durch den Kommentar "muss zu
maxVersionsKept im Backend passen". Ein Satz ist keine Zusicherung - beim
ersten Aendern haette der Dialog eine andere Zahl genannt als die, die der
Server anwendet.

Jetzt eine .env-Variable (Vorgabe 5), die der Server ueber
/api/v1/public/config mitliefert. Werte unter 1 werden verworfen: Die Zahl
geht als OFFSET in die Aufraeumabfrage, und OFFSET 0 loeschte jede Fassung -
aus "keine Grenze" wuerde "kein Verlauf".

Gemessen: MAX_VERSIONS_KEPT=3, Datei siebenmal ueberschrieben, uebrig
bleiben v6, v5, v4 bei aktueller v7.

Dazu ein README-Abschnitt "Versionen" - Standard aus, warum das so ist,
Kontingent, und dass jedes Strg+S in Office eine Fassung anlegt. Bisher
stand zu alldem nichts im README.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Opus 5 committed 2026-08-24 12:58:12 +02:00
1 parent 7fc8bb51d5
commit ebff565367
10 files changed
+119 -14

No files matched your search

+6 -2
View File
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'
import { versionsApi, type FileItem, type FileVersion } from '../api/client'
import { formatBytes } from '../pages/FileBrowser'
import { useOverlayDismiss } from '../hooks/useOverlayDismiss'
import { useAppSettings } from '../hooks/useAppSettings'
interface Props {
file: FileItem
@@ -9,8 +10,10 @@ interface Props {
onRestored: (updated: FileItem) => void
}
// Muss zu maxVersionsKept im Backend passen (internal/files/handler.go).
const MAX_VERSIONS_KEPT = 5
// Die Zahl kommt vom Server (MAX_VERSIONS_KEPT). Vorher stand sie hier fest
// mit dem Kommentar „muss zu maxVersionsKept im Backend passen" – ein Satz
// ist keine Zusicherung, und beim ersten Ändern nennt der Dialog sonst eine
// andere Zahl, als der Server anwendet.
function formatDate(iso: string): string {
return new Date(iso).toLocaleString(undefined, {
@@ -20,6 +23,7 @@ function formatDate(iso: string): string {
}
export default function VersionsDialog({ file, onClose, onRestored }: Props) {
const { maxVersionsKept: MAX_VERSIONS_KEPT } = useAppSettings()
const [versions, setVersions] = useState<FileVersion[]>([])
const [loading, setLoading] = useState(true)
const [restoring, setRestoring] = useState<string | null>(null)