From 095155d9ce346f3955bc6a50ff9d8b39d5ec8978 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 3 Nov 2020 12:20:46 +0100 Subject: [PATCH] Remove RepackSmall --- cmd/restic/cmd_prune.go | 20 +++++++------------- cmd/restic/integration_test.go | 9 --------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 605f6258e..f9f42d720 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -37,13 +37,12 @@ Exit status is 0 if the command was successful, and non-zero if there was any er // PruneOptions collects all options for the cleanup command. type PruneOptions struct { - DryRun bool - MaxUnused string - MaxUnusedPercent float64 - MaxUnusedBytes uint64 - MaxRepackSize string - MaxRepackBytes uint64 - // RepackSmall bool <- This option may be added later + DryRun bool + MaxUnused string + MaxUnusedPercent float64 + MaxUnusedBytes uint64 + MaxRepackSize string + MaxRepackBytes uint64 RepackCachableOnly bool } @@ -61,7 +60,6 @@ func addPruneOptions(c *cobra.Command) { f.StringVar(&pruneOptions.MaxUnused, "max-unused", "5%", "tolerate given `limit` of unused space (allowed suffixes: k/K, m/M, g/G, t/T or value in %)") f.StringVar(&pruneOptions.MaxRepackSize, "max-repack-size", "", "maximum `size` to repack (allowed suffixes: k/K, m/M, g/G, t/T)") f.BoolVar(&pruneOptions.RepackCachableOnly, "repack-cacheable-only", false, "only repack packs which are cacheable") - // f.BoolVar(&pruneOptions.RepackSmall, "repack-small", false, "also repack small packs") } func verifyPruneOptions(opts *PruneOptions) error { @@ -314,7 +312,7 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB case opts.RepackCachableOnly && p.tpe == restic.DataBlob, // if this is a data pack and --repack-cacheable-only is set => keep pack! - p.unusedBlobs == 0 && p.duplicateBlobs == 0 && p.tpe != restic.InvalidBlob: // && (!opts.RepackSmall || packSize >= repository.MinPackSize) + p.unusedBlobs == 0 && p.duplicateBlobs == 0 && p.tpe != restic.InvalidBlob: // All blobs in pack are used and not duplicates/mixed => keep pack! stats.packs.keep++ @@ -364,10 +362,6 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB return true case pj.tpe == restic.InvalidBlob && pi.tpe != restic.InvalidBlob: return false - //case opts.RepackSmall && pi.unusedSize+pi.usedSize < repository.MinPackSize && pj.unusedSize+pj.usedSize >= repository.MinPackSize: - // return true - //case opts.RepackSmall && pj.unusedSize+pj.usedSize < repository.MinPackSize && pi.unusedSize+pi.usedSize >= repository.MinPackSize: - // return false } return pi.unusedSize*pj.usedSize > pj.unusedSize*pi.usedSize }) diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 10af8701a..6aeeab634 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -1409,15 +1409,6 @@ func TestPrune(t *testing.T) { checkOpts := CheckOptions{ReadData: true} testPrune(t, opts, checkOpts) }) - - /* repack-small option will come in future - t.Run("Small", func(t *testing.T) { - opts = PruneOptions{MaxUnusedPercent: 100.0, RepackSmall: true} - // The test case only produces small files; hence no unused blobs should remain. - checkOpts = CheckOptions{ReadData: true, CheckUnused: true} - testPrune(t, opts, checkOpts) - }) - */ } func testPrune(t *testing.T, pruneOpts PruneOptions, checkOpts CheckOptions) {