Refactor condition for MaxRepackBytes

Don't depend on the string (opts.MaxRepackSize) for the condition,
instead check if there's a (positive) limit configured.
This commit is contained in:
Alexander Neumann 2020-11-03 13:28:21 +01:00
parent 7f86eb4ec0
commit 1ca60bccfb
1 changed files with 6 additions and 1 deletions

View File

@ -390,7 +390,12 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
for _, p := range repackCandidates {
reachedUnusedSizeAfter := (stats.size.unused-stats.size.remove-stats.size.repackrm < maxUnusedSizeAfter)
reachedRepackSize := (len(opts.MaxRepackSize) > 0 && stats.size.repack+p.unusedSize+p.usedSize > opts.MaxRepackBytes)
reachedRepackSize := false
if opts.MaxRepackBytes > 0 {
reachedRepackSize = stats.size.repack+p.unusedSize+p.usedSize > opts.MaxRepackBytes
}
switch {
case !reachedRepackSize && (p.duplicateBlobs > 0 || p.tpe == restic.InvalidBlob):
// repacking duplicates/mixed is only limited by repackSize