From 34175f273630f7d2324a4d6b5f9f2f7576dd6608 Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Sun, 4 Feb 2024 17:30:14 -0800 Subject: [PATCH] fix: wrong value passed to --max-unused when providing a custom prune policy --- internal/orchestrator/repo.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/orchestrator/repo.go b/internal/orchestrator/repo.go index 8740bf42..ab780be7 100644 --- a/internal/orchestrator/repo.go +++ b/internal/orchestrator/repo.go @@ -142,16 +142,17 @@ func (r *RepoOrchestrator) Prune(ctx context.Context, output io.Writer) error { defer r.mu.Unlock() policy := r.repoConfig.PrunePolicy + if policy == nil { + policy = &v1.PrunePolicy{ + MaxUnusedPercent: 25, + } + } var opts []restic.GenericOption - if policy != nil { - if policy.MaxUnusedBytes != 0 { - opts = append(opts, restic.WithFlags("--max-unused", fmt.Sprintf("%v", policy.MaxUnusedBytes))) - } else if policy.MaxUnusedPercent != 0 { - opts = append(opts, restic.WithFlags("--max-unused", fmt.Sprintf("%v", policy.MaxUnusedPercent))) - } - } else { - opts = append(opts, restic.WithFlags("--max-unused", "25%")) + if policy.MaxUnusedBytes != 0 { + opts = append(opts, restic.WithFlags("--max-unused", fmt.Sprintf("%vB", policy.MaxUnusedBytes))) + } else if policy.MaxUnusedPercent != 0 { + opts = append(opts, restic.WithFlags("--max-unused", fmt.Sprintf("%v%%", policy.MaxUnusedPercent))) } r.l.Debug("Prune snapshots")