mirror of
https://github.com/restic/restic.git
synced 2025-03-06 19:49:12 +00:00
prune: code cleanups
This commit is contained in:
parent
9be1bd2acc
commit
715d457aad
1 changed files with 5 additions and 11 deletions
|
@ -367,11 +367,6 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
repackPacks := restic.NewIDSet()
|
repackPacks := restic.NewIDSet()
|
||||||
|
|
||||||
var repackCandidates []packInfoWithID
|
var repackCandidates []packInfoWithID
|
||||||
|
|
||||||
keep := func(p packInfo) {
|
|
||||||
stats.packs.keep++
|
|
||||||
}
|
|
||||||
|
|
||||||
repoVersion := repo.Config().Version
|
repoVersion := repo.Config().Version
|
||||||
|
|
||||||
// loop over all packs and decide what to do
|
// loop over all packs and decide what to do
|
||||||
|
@ -386,8 +381,7 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.unusedSize+p.usedSize != uint64(packSize) &&
|
if p.unusedSize+p.usedSize != uint64(packSize) && p.usedBlobs != 0 {
|
||||||
p.usedBlobs != 0 {
|
|
||||||
// Pack size does not fit and pack is needed => error
|
// Pack size does not fit and pack is needed => error
|
||||||
// If the pack is not needed, this is no error, the pack can
|
// If the pack is not needed, this is no error, the pack can
|
||||||
// and will be simply removed, see below.
|
// and will be simply removed, see below.
|
||||||
|
@ -425,11 +419,11 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
|
|
||||||
case opts.RepackCachableOnly && p.tpe == restic.DataBlob:
|
case opts.RepackCachableOnly && p.tpe == restic.DataBlob:
|
||||||
// if this is a data pack and --repack-cacheable-only is set => keep pack!
|
// if this is a data pack and --repack-cacheable-only is set => keep pack!
|
||||||
keep(p)
|
stats.packs.keep++
|
||||||
|
|
||||||
case p.unusedBlobs == 0 && p.tpe != restic.InvalidBlob && !mustCompress:
|
case p.unusedBlobs == 0 && p.tpe != restic.InvalidBlob && !mustCompress:
|
||||||
// All blobs in pack are used and not mixed => keep pack!
|
// All blobs in pack are used and not mixed => keep pack!
|
||||||
keep(p)
|
stats.packs.keep++
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// all other packs are candidates for repacking
|
// all other packs are candidates for repacking
|
||||||
|
@ -506,7 +500,7 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case reachedRepackSize:
|
case reachedRepackSize:
|
||||||
keep(p.packInfo)
|
stats.packs.keep++
|
||||||
|
|
||||||
case p.tpe != restic.DataBlob, p.uncompressed:
|
case p.tpe != restic.DataBlob, p.uncompressed:
|
||||||
// repacking non-data packs / uncompressed-trees is only limited by repackSize
|
// repacking non-data packs / uncompressed-trees is only limited by repackSize
|
||||||
|
@ -514,7 +508,7 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
|
|
||||||
case reachedUnusedSizeAfter:
|
case reachedUnusedSizeAfter:
|
||||||
// for all other packs stop repacking if tolerated unused size is reached.
|
// for all other packs stop repacking if tolerated unused size is reached.
|
||||||
keep(p.packInfo)
|
stats.packs.keep++
|
||||||
|
|
||||||
default:
|
default:
|
||||||
repack(p.ID, p.packInfo)
|
repack(p.ID, p.packInfo)
|
||||||
|
|
Loading…
Add table
Reference in a new issue