mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
Merge pull request #3245 from aawsome/prune-fix-statistics-cacheable
prune: Fix statistics for --repack-cacheable-only
This commit is contained in:
commit
fb3cf3f885
1 changed files with 17 additions and 11 deletions
|
@ -298,6 +298,14 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
repackPacks := restic.NewIDSet()
|
repackPacks := restic.NewIDSet()
|
||||||
|
|
||||||
var repackCandidates []packInfoWithID
|
var repackCandidates []packInfoWithID
|
||||||
|
repackAllPacksWithDuplicates := true
|
||||||
|
|
||||||
|
keep := func(p packInfo) {
|
||||||
|
stats.packs.keep++
|
||||||
|
if p.duplicateBlobs > 0 {
|
||||||
|
repackAllPacksWithDuplicates = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// loop over all packs and decide what to do
|
// loop over all packs and decide what to do
|
||||||
bar := newProgressMax(!gopts.Quiet, uint64(len(indexPack)), "packs processed")
|
bar := newProgressMax(!gopts.Quiet, uint64(len(indexPack)), "packs processed")
|
||||||
|
@ -341,11 +349,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!
|
||||||
stats.packs.keep++
|
keep(p)
|
||||||
|
|
||||||
case p.unusedBlobs == 0 && p.duplicateBlobs == 0 && p.tpe != restic.InvalidBlob:
|
case p.unusedBlobs == 0 && p.duplicateBlobs == 0 && p.tpe != restic.InvalidBlob:
|
||||||
// All blobs in pack are used and not duplicates/mixed => keep pack!
|
// All blobs in pack are used and not duplicates/mixed => keep pack!
|
||||||
stats.packs.keep++
|
keep(p)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// all other packs are candidates for repacking
|
// all other packs are candidates for repacking
|
||||||
|
@ -385,8 +393,6 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repackAllPacksWithDuplicates := true
|
|
||||||
|
|
||||||
// calculate limit for number of unused bytes in the repo after repacking
|
// calculate limit for number of unused bytes in the repo after repacking
|
||||||
maxUnusedSizeAfter := opts.maxUnusedBytes(stats.size.used)
|
maxUnusedSizeAfter := opts.maxUnusedBytes(stats.size.used)
|
||||||
|
|
||||||
|
@ -428,16 +434,16 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case !reachedRepackSize && (p.duplicateBlobs > 0 || p.tpe != restic.DataBlob):
|
case reachedRepackSize:
|
||||||
// repacking duplicates/mixed is only limited by repackSize
|
keep(p.packInfo)
|
||||||
|
|
||||||
|
case p.duplicateBlobs > 0, p.tpe != restic.DataBlob:
|
||||||
|
// repacking duplicates/non-data is only limited by repackSize
|
||||||
repack(p.ID, p.packInfo)
|
repack(p.ID, p.packInfo)
|
||||||
|
|
||||||
case reachedUnusedSizeAfter, reachedRepackSize:
|
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.
|
||||||
stats.packs.keep++
|
keep(p.packInfo)
|
||||||
if p.duplicateBlobs > 0 {
|
|
||||||
repackAllPacksWithDuplicates = false
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
repack(p.ID, p.packInfo)
|
repack(p.ID, p.packInfo)
|
||||||
|
|
Loading…
Reference in a new issue