Skip to content

Commit

Permalink
fix: wrong value passed to --max-unused when providing a custom prune…
Browse files Browse the repository at this point in the history
… policy
  • Loading branch information
garethgeorge committed Feb 8, 2024
1 parent 055ff64 commit 34175f2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions internal/orchestrator/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 34175f2

Please sign in to comment.