R-1252 (P2): a rejected or absent backup block never deletes second-drive copies — reconcile only on a valid classification; a rejected block is said on the app's status and once a day to the operator (backup_run_failures); kept copies stay kept (H2); Remove drops the kept records it deleted (H9). Commit only.
gates / gates (push) Successful in 1m18s

This commit is contained in:
2026-10-24 20:07:16 +02:00
parent 062f9b41d9
commit 518a13592d
16 changed files with 400 additions and 6 deletions
+40
View File
@@ -57,6 +57,46 @@ func (m *Manager) releaseKeptCopy(path string) {
}
}
// keptCopyRels (R-1252, HUNT-2 H2) is the slash-form path, relative to destBase, of every kept copy recorded inside
// it — added to the reconcile's keep set so a kept copy is never reconciled away while its record stays.
func (m *Manager) keptCopyRels(destBase string) []string {
if m.settings == nil {
return nil
}
base := filepath.Clean(destBase)
var out []string
for _, k := range m.settings.GetKeptCopies() {
if filepath.Clean(k.DestBase) != base {
continue
}
rel, err := filepath.Rel(base, filepath.Clean(k.Path))
if err != nil || rel == "." || rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
continue
}
out = append(out, filepath.ToSlash(rel))
}
return out
}
// dropKeptCopiesUnder (R-1252, HUNT-2 H9) drops the records of kept copies inside dir — called after dir itself was
// deleted (Remove with „remove backups"), so the backups page never lists a copy that is gone.
func (m *Manager) dropKeptCopiesUnder(dir string) {
if m.settings == nil {
return
}
d := filepath.Clean(dir)
for _, k := range m.settings.GetKeptCopies() {
p := filepath.Clean(k.Path)
if p == d || strings.HasPrefix(p, d+string(filepath.Separator)) {
if err := m.settings.DropKeptCopy(k.ID); err != nil {
m.logger.Printf("[WARN] [backup] the record of the deleted kept copy %s could not be dropped: %v", p, err)
continue
}
m.logger.Printf("[INFO] [backup] kept copy %s was deleted with its app's backups — record dropped", p)
}
}
}
// KeptCopies lists the kept copies for the backups page.
func (m *Manager) KeptCopies() []settings.KeptCopy {
if m.settings == nil {