2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

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

View File

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