diff options
| author | chrislu <chris.lu@gmail.com> | 2022-09-14 00:07:27 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-09-14 00:07:27 -0700 |
| commit | 956ce6416fae66646344782cc7f6f557708eb1f4 (patch) | |
| tree | 816b56483f063eebf9be9c9fe41d7410aba661f3 /weed/filer/arangodb/helpers.go | |
| parent | 3f4400dc03c3c1476f3edf89d3da31f57bcd4278 (diff) | |
| parent | 58d18b68d8ca463cef2a817f69f62e7b2fbd61f0 (diff) | |
| download | seaweedfs-956ce6416fae66646344782cc7f6f557708eb1f4.tar.xz seaweedfs-956ce6416fae66646344782cc7f6f557708eb1f4.zip | |
Merge branch 'master' into message_send
Diffstat (limited to 'weed/filer/arangodb/helpers.go')
| -rw-r--r-- | weed/filer/arangodb/helpers.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/weed/filer/arangodb/helpers.go b/weed/filer/arangodb/helpers.go index 3f36acb0a..776e6d1b8 100644 --- a/weed/filer/arangodb/helpers.go +++ b/weed/filer/arangodb/helpers.go @@ -12,7 +12,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/util" ) -//convert a string into arango-key safe hex bytes hash +// convert a string into arango-key safe hex bytes hash func hashString(dir string) string { h := md5.New() io.WriteString(h, dir) @@ -98,8 +98,26 @@ func (store *ArangodbStore) ensureBucket(ctx context.Context, bucket string) (bc return store.buckets[bucket], nil } +// transform to an arango compliant name +func bucketToCollectionName(s string) string { + if len(s) == 0 { + return "" + } + // replace all "." with _ + s = strings.ReplaceAll(s, ".", "_") + + // if starts with number or '.' then add a special prefix + if (s[0] >= '0' && s[0] <= '9') || (s[0] == '.' || s[0] == '_' || s[0] == '-') { + s = "xN--" + s + } + return s +} + // creates collection if not exist, ensures indices if not exist -func (store *ArangodbStore) ensureCollection(ctx context.Context, name string) (c driver.Collection, err error) { +func (store *ArangodbStore) ensureCollection(ctx context.Context, bucket_name string) (c driver.Collection, err error) { + // convert the bucket to collection name + name := bucketToCollectionName(bucket_name) + ok, err := store.database.CollectionExists(ctx, name) if err != nil { return |
