From 7dd480acad237f2aa5842dc14b1de051ddcae1fb Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 1 Oct 2024 10:16:21 -0700 Subject: [PATCH] handle missing leading zero padding in replica --- weed/storage/super_block/replica_placement.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/weed/storage/super_block/replica_placement.go b/weed/storage/super_block/replica_placement.go index 9a59eb258..b2bf21fcb 100644 --- a/weed/storage/super_block/replica_placement.go +++ b/weed/storage/super_block/replica_placement.go @@ -12,6 +12,14 @@ type ReplicaPlacement struct { func NewReplicaPlacementFromString(t string) (*ReplicaPlacement, error) { rp := &ReplicaPlacement{} + switch len(t) { + case 0: + t = "000" + case 1: + t = "00" + t + case 2: + t = "0" + t + } for i, c := range t { count := int(c - '0') if count < 0 {