aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-16 11:10:12 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-16 11:10:12 -0700
commit68d39c86f1339d4bf93ff772cf8644155dae81a0 (patch)
tree187ec5f5207411748e6f363e9e09e9adbafcb494
parentee1fc6558a6db603c4eaac9f3cee11873f934f56 (diff)
downloadseaweedfs-68d39c86f1339d4bf93ff772cf8644155dae81a0.tar.xz
seaweedfs-68d39c86f1339d4bf93ff772cf8644155dae81a0.zip
mysql, postgres, cassandra: change kv key to base64 encoding
The exisitng key-value operation for stores using mysql, postgres, and maybe cassandra are already broken. The kv is used to store hardlink, filer store signature and replication progress. So users using hardlink and also uses mysql, postgres, or cassandra will have broken hard links. Users using filer.sync will need to re-sync the files.
-rw-r--r--weed/filer/abstract_sql/abstract_sql_store_kv.go5
-rw-r--r--weed/filer/cassandra/cassandra_store_kv.go5
2 files changed, 6 insertions, 4 deletions
diff --git a/weed/filer/abstract_sql/abstract_sql_store_kv.go b/weed/filer/abstract_sql/abstract_sql_store_kv.go
index b5a662c6b..c368059df 100644
--- a/weed/filer/abstract_sql/abstract_sql_store_kv.go
+++ b/weed/filer/abstract_sql/abstract_sql_store_kv.go
@@ -3,6 +3,7 @@ package abstract_sql
import (
"context"
"database/sql"
+ "encoding/base64"
"fmt"
"strings"
@@ -80,8 +81,8 @@ func genDirAndName(key []byte) (dirStr string, dirHash int64, name string) {
}
dirHash = int64(util.BytesToUint64(key[:8]))
- dirStr = string(key[:8])
- name = string(key[8:])
+ dirStr = base64.StdEncoding.EncodeToString(key[:8])
+ name = base64.StdEncoding.EncodeToString(key[8:])
return
}
diff --git a/weed/filer/cassandra/cassandra_store_kv.go b/weed/filer/cassandra/cassandra_store_kv.go
index b6238cf0e..dafa9bb15 100644
--- a/weed/filer/cassandra/cassandra_store_kv.go
+++ b/weed/filer/cassandra/cassandra_store_kv.go
@@ -2,6 +2,7 @@ package cassandra
import (
"context"
+ "encoding/base64"
"fmt"
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/gocql/gocql"
@@ -54,8 +55,8 @@ func genDirAndName(key []byte) (dir string, name string) {
key = append(key, 0)
}
- dir = string(key[:8])
- name = string(key[8:])
+ dir = base64.StdEncoding.EncodeToString(key[:8])
+ name = base64.StdEncoding.EncodeToString(key[8:])
return
}