mirror of
https://github.com/restic/restic.git
synced 2026-05-24 11:05:26 +00:00
Add upper bound for t in --read-data-subset=n/t (#2304)
* Add upper bound for t in --read-data-subset=n/t * Add changelog entry
This commit is contained in:
@@ -67,11 +67,17 @@ func checkFlags(opts CheckOptions) error {
|
||||
if dataSubset[0] == 0 || dataSubset[1] == 0 || dataSubset[0] > dataSubset[1] {
|
||||
return errors.Fatalf("check flag --read-data-subset=n/t values must be positive integers, and n <= t, e.g. --read-data-subset=1/2")
|
||||
}
|
||||
if dataSubset[1] > totalBucketsMax {
|
||||
return errors.Fatalf("check flag --read-data-subset=n/t t must be at most %d", totalBucketsMax)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// See doReadData in runCheck below for why this is 256.
|
||||
const totalBucketsMax = 256
|
||||
|
||||
// stringToIntSlice converts string to []uint, using '/' as element separator
|
||||
func stringToIntSlice(param string) (split []uint, err error) {
|
||||
if param == "" {
|
||||
@@ -257,6 +263,8 @@ func runCheck(opts CheckOptions, gopts GlobalOptions, args []string) error {
|
||||
doReadData := func(bucket, totalBuckets uint) {
|
||||
packs := restic.IDSet{}
|
||||
for pack := range chkr.GetPacks() {
|
||||
// If we ever check more than the first byte
|
||||
// of pack, update totalBucketsMax.
|
||||
if (uint(pack[0]) % totalBuckets) == (bucket - 1) {
|
||||
packs.Insert(pack)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user