mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
prune: Handle --max-repack-size=0 as expected
Previously the flag was ignored and `--max-repack-size=1` had to be used.
This commit is contained in:
parent
882d58abce
commit
0cfdb82ea4
8
changelog/unreleased/pull-3591
Normal file
8
changelog/unreleased/pull-3591
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Bugfix: Fix handling of `prune --max-repack-size=0`
|
||||||
|
|
||||||
|
Restic ignored the `--max-repack-size` option when passing a value of 0. This
|
||||||
|
has been fixed.
|
||||||
|
|
||||||
|
As a workaround, `--max-repack-size=1` can be used with older versions of restic.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/3591
|
@ -66,6 +66,7 @@ func addPruneOptions(c *cobra.Command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func verifyPruneOptions(opts *PruneOptions) error {
|
func verifyPruneOptions(opts *PruneOptions) error {
|
||||||
|
opts.MaxRepackBytes = math.MaxUint64
|
||||||
if len(opts.MaxRepackSize) > 0 {
|
if len(opts.MaxRepackSize) > 0 {
|
||||||
size, err := parseSizeStr(opts.MaxRepackSize)
|
size, err := parseSizeStr(opts.MaxRepackSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -418,11 +419,7 @@ 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 := 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:
|
case reachedRepackSize:
|
||||||
|
Loading…
Reference in New Issue
Block a user