diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index 31c61e3a5a..2382e67cd0 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -853,7 +853,7 @@ func (c *Client) GenerateToken(ctx context.Context, auth eosclient.Authorization expiration := strconv.FormatInt(time.Now().Add(time.Duration(c.opt.TokenExpiry)*time.Second).Unix(), 10) args := []string{"token", "--permission", a.Permissions, "--tree", "--path", p, "--expires", expiration} stdout, _, err := c.executeEOS(ctx, args, auth) - return stdout, err + return strings.TrimSpace(stdout), err } func (c *Client) getVersionFolderInode(ctx context.Context, auth eosclient.Authorization, p string) (uint64, error) { diff --git a/pkg/storage/fs/cephfs/connections.go b/pkg/storage/fs/cephfs/connections.go index 4dd8383bca..570f0bcbb3 100644 --- a/pkg/storage/fs/cephfs/connections.go +++ b/pkg/storage/fs/cephfs/connections.go @@ -109,9 +109,9 @@ func (c *connections) clearCache() { type adminConn struct { // indexPoolName string - subvolAdmin *admin.FSAdmin - adminMount Mount - radosConn *rados2.Conn + subvolAdmin *admin.FSAdmin + adminMount Mount + radosConn *rados2.Conn // radosIO *rados2.IOContext } @@ -134,32 +134,32 @@ func newAdminConn(conf *Options) *adminConn { // TODO: May use later for file ids /* - pools, err := rados.ListPools() - if err != nil { - rados.Shutdown() - return nil - } - - var radosIO *rados2.IOContext - poolName := conf.IndexPool - if in(poolName, pools) { - radosIO, err = rados.OpenIOContext(poolName) - if err != nil { - rados.Shutdown() - return nil - } - } else { - err = rados.MakePool(poolName) + pools, err := rados.ListPools() if err != nil { rados.Shutdown() return nil } - radosIO, err = rados.OpenIOContext(poolName) - if err != nil { - rados.Shutdown() - return nil + + var radosIO *rados2.IOContext + poolName := conf.IndexPool + if in(poolName, pools) { + radosIO, err = rados.OpenIOContext(poolName) + if err != nil { + rados.Shutdown() + return nil + } + } else { + err = rados.MakePool(poolName) + if err != nil { + rados.Shutdown() + return nil + } + radosIO, err = rados.OpenIOContext(poolName) + if err != nil { + rados.Shutdown() + return nil + } } - } */ mount, err := cephfs2.CreateFromRados(rados) @@ -174,7 +174,7 @@ func newAdminConn(conf *Options) *adminConn { return nil } - return &adminConn { + return &adminConn{ // poolName, admin.NewFromConn(rados), mount, diff --git a/pkg/storage/fs/cephfs/options.go b/pkg/storage/fs/cephfs/options.go index 95ec35413f..8ca97dbbaf 100644 --- a/pkg/storage/fs/cephfs/options.go +++ b/pkg/storage/fs/cephfs/options.go @@ -29,8 +29,8 @@ import ( // Options for the cephfs module type Options struct { - ClientID string `mapstructure:"client_id"` - Config string `mapstructure:"config"` + ClientID string `mapstructure:"client_id"` + Config string `mapstructure:"config"` GatewaySvc string `mapstructure:"gatewaysvc"` IndexPool string `mapstructure:"index_pool"` Keyring string `mapstructure:"keyring"` diff --git a/pkg/storage/fs/cephfs/utils.go b/pkg/storage/fs/cephfs/utils.go index b54b76cb91..f2b9a4f703 100644 --- a/pkg/storage/fs/cephfs/utils.go +++ b/pkg/storage/fs/cephfs/utils.go @@ -100,7 +100,7 @@ func (fs *cephfs) getFIDPath(cv *cacheVal, path string) (fid string, err error) return fs.makeFIDPath(string(buffer)), err } - */ +*/ func calcChecksum(filepath string, mt Mount, stat Statx) (checksum string, err error) { file, err := mt.Open(filepath, os.O_RDONLY, 0) @@ -247,4 +247,4 @@ func (fs *cephfs) resolveIndex(oid string) (fullPath string, err error) { currPath.Reset() } } - */ +*/ diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 406d7ec211..dde92972df 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -870,7 +870,6 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys return nil, errors.Wrap(err, "eosfs: error resolving reference") } - // if path is home we need to add in the response any shadow folder in the shadow homedirectory. if fs.conf.EnableHome { return fs.listWithHome(ctx, p) } @@ -878,6 +877,19 @@ func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys return fs.listWithNominalHome(ctx, p) } +func (fs *eosfs) listWithHome(ctx context.Context, p string) ([]*provider.ResourceInfo, error) { + if fs.isShareFolderRoot(ctx, p) { + return fs.listShareFolderRoot(ctx, p) + } + + if fs.isShareFolderChild(ctx, p) { + return nil, errtypes.PermissionDenied("eos: error listing folders inside the shared folder, only file references are stored inside") + } + + // path points to a resource in the nominal home + return fs.listWithNominalHome(ctx, p) +} + func (fs *eosfs) listWithNominalHome(ctx context.Context, p string) (finfos []*provider.ResourceInfo, err error) { log := appctx.GetLogger(ctx) fn := fs.wrap(ctx, p) @@ -907,7 +919,8 @@ func (fs *eosfs) listWithNominalHome(ctx context.Context, p string) (finfos []*p } // Remove the hidden folders in the topmost directory - if finfo, err := fs.convertToResourceInfo(ctx, eosFileInfo); err == nil && finfo.Path != "/" && !strings.HasPrefix(finfo.Path, "/.") { + if finfo, err := fs.convertToResourceInfo(ctx, eosFileInfo); err == nil && + finfo.Path != "/" && !strings.HasPrefix(finfo.Path, "/.") { finfos = append(finfos, finfo) } } @@ -915,61 +928,6 @@ func (fs *eosfs) listWithNominalHome(ctx context.Context, p string) (finfos []*p return finfos, nil } -func (fs *eosfs) listWithHome(ctx context.Context, p string) ([]*provider.ResourceInfo, error) { - if p == "/" { - return fs.listHome(ctx) - } - - if fs.isShareFolderRoot(ctx, p) { - return fs.listShareFolderRoot(ctx, p) - } - - if fs.isShareFolderChild(ctx, p) { - return nil, errtypes.PermissionDenied("eosfs: error listing folders inside the shared folder, only file references are stored inside") - } - - // path points to a resource in the nominal home - return fs.listWithNominalHome(ctx, p) -} - -func (fs *eosfs) listHome(ctx context.Context) ([]*provider.ResourceInfo, error) { - fns := []string{fs.wrap(ctx, "/"), fs.wrapShadow(ctx, "/")} - - u, err := getUser(ctx) - if err != nil { - return nil, errors.Wrap(err, "eosfs: no user in ctx") - } - // lightweight accounts don't have home folders, so we're passing an empty string as path - auth, err := fs.getUserAuth(ctx, u, "") - if err != nil { - return nil, err - } - - finfos := []*provider.ResourceInfo{} - for _, fn := range fns { - eosFileInfos, err := fs.c.List(ctx, auth, fn) - if err != nil { - return nil, errors.Wrap(err, "eosfs: error listing") - } - - for _, eosFileInfo := range eosFileInfos { - // filter out sys files - if !fs.conf.ShowHiddenSysFiles { - base := path.Base(eosFileInfo.File) - if hiddenReg.MatchString(base) { - continue - } - } - - if finfo, err := fs.convertToResourceInfo(ctx, eosFileInfo); err == nil && finfo.Path != "/" && !strings.HasPrefix(finfo.Path, "/.") { - finfos = append(finfos, finfo) - } - } - - } - return finfos, nil -} - func (fs *eosfs) listShareFolderRoot(ctx context.Context, p string) (finfos []*provider.ResourceInfo, err error) { fn := fs.wrapShadow(ctx, p) @@ -1763,8 +1721,8 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) ( } var xs provider.ResourceChecksum - if eosFileInfo.XS != nil { - xs.Sum = eosFileInfo.XS.XSSum + if eosFileInfo.Size != 0 && eosFileInfo.XS != nil { + xs.Sum = strings.TrimLeft(eosFileInfo.XS.XSSum, "0") switch eosFileInfo.XS.XSType { case "adler": xs.Type = provider.ResourceChecksumType_RESOURCE_CHECKSUM_TYPE_ADLER32