check: Fix crash of --read-data-subset=x% on empty repository

Rounding up to at least one pack file should only be done if at least a
pack file exists.
This commit is contained in:
Michael Eischer
2021-02-27 16:05:36 +01:00
parent 4baebdc6f5
commit 9e852af5be
3 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -331,7 +331,7 @@ func selectPacksByBucket(allPacks map[restic.ID]int64, bucket, totalBuckets uint
func selectRandomPacksByPercentage(allPacks map[restic.ID]int64, percentage float64) map[restic.ID]int64 {
packCount := len(allPacks)
packsToCheck := int(float64(packCount) * (percentage / 100.0))
if packsToCheck < 1 {
if packCount > 0 && packsToCheck < 1 {
packsToCheck = 1
}
timeNs := time.Now().UnixNano()