From ed37f2382d3e06230ae80461ef038c211aa51829 Mon Sep 17 00:00:00 2001 From: Hugo Gonzalez Labrador Date: Wed, 24 Apr 2024 15:43:48 +0200 Subject: [PATCH] remove more obsolete code --- pkg/storage/utils/eosfs/eosfs.go | 60 ------------------------------- pkg/storage/utils/eosfs/upload.go | 4 --- 2 files changed, 64 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 71de5299c7..3a5577cf65 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -309,19 +309,6 @@ func (fs *eosfs) getInternalHome(ctx context.Context) (string, error) { return relativeHome, nil } -func (fs *eosfs) wrapShadow(ctx context.Context, fn string) (internal string) { - if fs.conf.EnableHome { - layout, err := fs.getInternalHome(ctx) - if err != nil { - panic(err) - } - internal = path.Join(fs.conf.ShadowNamespace, layout, fn) - } else { - internal = path.Join(fs.conf.ShadowNamespace, fn) - } - return -} - func (fs *eosfs) wrap(ctx context.Context, fn string) (internal string) { if fs.conf.EnableHome { layout, err := fs.getInternalHome(ctx) @@ -460,20 +447,6 @@ func (fs *eosfs) getPath(ctx context.Context, id *provider.ResourceId) (string, return fs.unwrap(ctx, eosFileInfo.File) } -func (fs *eosfs) isShareFolder(ctx context.Context, p string) bool { - return strings.HasPrefix(p, fs.conf.ShareFolder) -} - -func (fs *eosfs) isShareFolderRoot(ctx context.Context, p string) bool { - return path.Clean(p) == fs.conf.ShareFolder -} - -func (fs *eosfs) isShareFolderChild(ctx context.Context, p string) bool { - p = path.Clean(p) - vals := strings.Split(p, fs.conf.ShareFolder+"/") - return len(vals) > 1 && vals[1] != "" -} - func (fs *eosfs) GetPathByID(ctx context.Context, id *provider.ResourceId) (string, error) { fid, err := strconv.ParseUint(id.OpaqueId, 10, 64) if err != nil { @@ -1258,25 +1231,6 @@ func (fs *eosfs) GetMD(ctx context.Context, ref *provider.Reference, mdKeys []st return fs.convertToResourceInfo(ctx, eosFileInfo) } -func (fs *eosfs) getMDShareFolder(ctx context.Context, p string, mdKeys []string) (*provider.ResourceInfo, error) { - fn := fs.wrapShadow(ctx, p) - - auth, err := fs.getRootAuth(ctx) - if err != nil { - return nil, err - } - - eosFileInfo, err := fs.c.GetFileInfoByPath(ctx, auth, fn) - if err != nil { - return nil, err - } - - if fs.isShareFolderRoot(ctx, p) { - return fs.convertToResourceInfo(ctx, eosFileInfo) - } - return fs.convertToFileReference(ctx, eosFileInfo) -} - func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys []string) ([]*provider.ResourceInfo, error) { p, err := fs.resolve(ctx, ref) if err != nil { @@ -1872,20 +1826,6 @@ func (fs *eosfs) convertToResourceInfo(ctx context.Context, eosFileInfo *eosclie return fs.convert(ctx, eosFileInfo) } -func (fs *eosfs) convertToFileReference(ctx context.Context, eosFileInfo *eosclient.FileInfo) (*provider.ResourceInfo, error) { - info, err := fs.convert(ctx, eosFileInfo) - if err != nil { - return nil, err - } - info.Type = provider.ResourceType_RESOURCE_TYPE_REFERENCE - val, ok := eosFileInfo.Attrs["reva.target"] - if !ok || val == "" { - return nil, errtypes.InternalError("eosfs: reference does not contain target: target=" + val + " file=" + eosFileInfo.File) - } - info.Target = val - return info, nil -} - // permissionSet returns the permission set for the current user. func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileInfo, owner *userpb.UserId) *provider.ResourcePermissions { u, ok := appctx.ContextGetUser(ctx) diff --git a/pkg/storage/utils/eosfs/upload.go b/pkg/storage/utils/eosfs/upload.go index 2c53920fe1..0e5f4f5f91 100644 --- a/pkg/storage/utils/eosfs/upload.go +++ b/pkg/storage/utils/eosfs/upload.go @@ -36,10 +36,6 @@ func (fs *eosfs) Upload(ctx context.Context, ref *provider.Reference, r io.ReadC return errors.Wrap(err, "eos: error resolving reference") } - if fs.isShareFolder(ctx, p) { - return errtypes.PermissionDenied("eos: cannot upload under the virtual share folder") - } - ok, err := chunking.IsChunked(p) if err != nil { return errors.Wrap(err, "eos: error checking path")