From d7dc19a4962f241311a6bb0caafb2862244aa2b0 Mon Sep 17 00:00:00 2001
From: Alexander Weiss <alex@weissfam.de>
Date: Fri, 15 Jan 2021 16:42:04 +0100
Subject: [PATCH] prune: Always repack packs containing tree blobs

---
 cmd/restic/cmd_prune.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go
index bdad4efd9..9198dbc5c 100644
--- a/cmd/restic/cmd_prune.go
+++ b/cmd/restic/cmd_prune.go
@@ -390,7 +390,7 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
 	// This is equivalent to sorting by unused / total space.
 	// Instead of unused[i] / used[i] > unused[j] / used[j] we use
 	// unused[i] * used[j] > unused[j] * used[i] as uint32*uint32 < uint64
-	// Morover duplicates and mixed are sorted to the beginning
+	// Morover duplicates and packs containing trees are sorted to the beginning
 	sort.Slice(repackCandidates, func(i, j int) bool {
 		pi := repackCandidates[i].packInfo
 		pj := repackCandidates[j].packInfo
@@ -399,9 +399,9 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
 			return true
 		case pj.duplicateBlobs > 0 && pi.duplicateBlobs == 0:
 			return false
-		case pi.tpe == restic.InvalidBlob && pj.tpe != restic.InvalidBlob:
+		case pi.tpe != restic.DataBlob && pj.tpe == restic.DataBlob:
 			return true
-		case pj.tpe == restic.InvalidBlob && pi.tpe != restic.InvalidBlob:
+		case pj.tpe != restic.DataBlob && pi.tpe == restic.DataBlob:
 			return false
 		}
 		return pi.unusedSize*pj.usedSize > pj.unusedSize*pi.usedSize
@@ -424,7 +424,7 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB
 		}
 
 		switch {
-		case !reachedRepackSize && (p.duplicateBlobs > 0 || p.tpe == restic.InvalidBlob):
+		case !reachedRepackSize && (p.duplicateBlobs > 0 || p.tpe != restic.DataBlob):
 			// repacking duplicates/mixed is only limited by repackSize
 			repack(p.ID, p.packInfo)