From 4c17d56ae0a3b4a39850728e8bf3694771e032bb Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Tue, 29 Sep 2020 14:49:59 +0200 Subject: [PATCH] Fix config --- accounts/pkg/flagset/flagset.go | 4 ++-- accounts/pkg/storage/cs3.go | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/accounts/pkg/flagset/flagset.go b/accounts/pkg/flagset/flagset.go index 98da16cc67..7956d58ff0 100644 --- a/accounts/pkg/flagset/flagset.go +++ b/accounts/pkg/flagset/flagset.go @@ -103,8 +103,8 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { Name: "storage-disk-path", Value: "", Usage: "Path on the local disk, e.g. /var/tmp/ocis-accounts", - EnvVars: []string{"ACCOUNTS_STORAGE_CS3_PROVIDER_ADDR"}, - Destination: &cfg.Repo.CS3.ProviderAddr, + EnvVars: []string{"ACCOUNTS_STORAGE_DISK_PATH"}, + Destination: &cfg.Repo.Disk.Path, }, &cli.StringFlag{ Name: "storage-cs3-provider-addr", diff --git a/accounts/pkg/storage/cs3.go b/accounts/pkg/storage/cs3.go index 39865a39a8..27ade503ba 100644 --- a/accounts/pkg/storage/cs3.go +++ b/accounts/pkg/storage/cs3.go @@ -5,6 +5,11 @@ import ( "context" "encoding/json" "fmt" + "io/ioutil" + "net/http" + "path" + "strings" + user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" v1beta11 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -15,9 +20,6 @@ import ( "github.com/owncloud/ocis/accounts/pkg/config" "github.com/owncloud/ocis/accounts/pkg/proto/v0" "google.golang.org/grpc/metadata" - "io/ioutil" - "net/http" - "path" ) type CS3Repo struct { @@ -243,11 +245,11 @@ func (r CS3Repo) authenticate(ctx context.Context) (token string, err error) { } func (r CS3Repo) accountUrl(id string) string { - return path.Join(r.cfg.Repo.CS3.DriverURL, r.cfg.Repo.CS3.DataPrefix, accountsFolder, id) + return singleJoiningSlash(r.cfg.Repo.CS3.DriverURL, path.Join(r.cfg.Repo.CS3.DataPrefix, accountsFolder, id)) } func (r CS3Repo) groupUrl(id string) string { - return path.Join(r.cfg.Repo.CS3.DriverURL, r.cfg.Repo.CS3.DataPrefix, groupsFolder, id) + return singleJoiningSlash(r.cfg.Repo.CS3.DriverURL, path.Join(r.cfg.Repo.CS3.DataPrefix, groupsFolder, id)) } func (r CS3Repo) makeRootDirIfNotExist(ctx context.Context, folder string) error { @@ -275,3 +277,16 @@ func (r CS3Repo) makeRootDirIfNotExist(ctx context.Context, folder string) error return nil } + +// TODO: this is copied from proxy. Find a better solution or move it to ocis-pkg +func singleJoiningSlash(a, b string) string { + aslash := strings.HasSuffix(a, "/") + bslash := strings.HasPrefix(b, "/") + switch { + case aslash && bslash: + return a + b[1:] + case !aslash && !bslash: + return a + "/" + b + } + return a + b +}