From 6a497881471f3bcf3af0a898888ff36d9a059620 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Fri, 19 Nov 2021 17:00:52 +0100 Subject: [PATCH] Use root auth to not use the recycle bin --- pkg/storage/utils/eosfs/eosfs.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index f01217023b..7c6671e03e 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -1286,23 +1286,27 @@ func (fs *eosfs) Delete(ctx context.Context, ref *provider.Reference) error { return fs.c.Remove(ctx, auth, fn, false) } +func getRootAuth() eosclient.Authorization { + return eosclient.Authorization{ + Role: eosclient.Role{ + UID: "0", + GID: "0", + }, + } +} + func (fs *eosfs) deleteShadow(ctx context.Context, p string) error { if fs.isShareFolderRoot(ctx, p) { return errtypes.PermissionDenied("eosfs: cannot delete the virtual share folder") } if fs.isShareFolderChild(ctx, p) { - u, err := getUser(ctx) - if err != nil { - return errors.Wrap(err, "eosfs: no user in ctx") - } - fn := fs.wrapShadow(ctx, p) - - auth, err := fs.getUserAuth(ctx, u, "") - if err != nil { - return err - } + + // in order to remove definitely the folder or the file + // without moving it to the recycle bin, we should take + // the priviledges of the root + auth := getRootAuth() return fs.c.Remove(ctx, auth, fn, true) }