Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix bug when reading back the replica settings!

Chris Lu6084e7670a12
diff --git a/go/storage/replica_placement.go b/go/storage/replica_placement.go
index 55428749bf..696888cd8f 100644
--- a/go/storage/replica_placement.go
+++ b/go/storage/replica_placement.go
@@ -36,7 +36,7 @@ func NewReplicaPlacementFromString(t string) (*ReplicaPlacement, error) {
}
func NewReplicaPlacementFromByte(b byte) (*ReplicaPlacement, error) {
- return NewReplicaPlacementFromString(fmt.Sprintf("%d", b))
+ return NewReplicaPlacementFromString(fmt.Sprintf("%03d", b))
}
func (rp *ReplicaPlacement) Byte() byte {
diff --git a/go/storage/replica_placement_test.go b/go/storage/replica_placement_test.go
new file mode 100644
index 0000000000..9c2161e944
--- /dev/null
+++ b/go/storage/replica_placement_test.go
@@ -0,0 +1,14 @@
+package storage
+
+import (
+ "testing"
+)
+
+func TestReplicaPlacemnetSerialDeserial(t *testing.T) {
+ rp, _ := NewReplicaPlacementFromString("001")
+ new_rp, _ := NewReplicaPlacementFromByte(rp.Byte())
+ if rp.String() != new_rp.String() {
+ println("expected:", rp.String(), "actual:", new_rp.String())
+ t.Fail()
+ }
+}