From dccc6cb37d5241c5b75ec02e6c527c5777f2bfda Mon Sep 17 00:00:00 2001 From: Ilja Neumann Date: Thu, 14 Jan 2021 14:56:32 +0100 Subject: [PATCH] Fix trash-bin purge --- internal/http/services/owncloud/ocdav/trashbin.go | 5 +++-- pkg/storage/fs/ocis/recycle.go | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index 4fa4e3dc1de..1d0401c8435 100644 --- a/internal/http/services/owncloud/ocdav/trashbin.go +++ b/internal/http/services/owncloud/ocdav/trashbin.go @@ -117,12 +117,13 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler { h.restore(w, r, s, u, dst, key) return } - if key != "" && r.Method == "DELETE" { + + if r.Method == "DELETE" { h.delete(w, r, s, u, key) return } - http.Error(w, "501 Forbidden", http.StatusNotImplemented) + http.Error(w, "501 Not implemented", http.StatusNotImplemented) }) } diff --git a/pkg/storage/fs/ocis/recycle.go b/pkg/storage/fs/ocis/recycle.go index 577298cf089..16fe11c4db0 100644 --- a/pkg/storage/fs/ocis/recycle.go +++ b/pkg/storage/fs/ocis/recycle.go @@ -233,14 +233,15 @@ func (fs *ocisfs) PurgeRecycleItem(ctx context.Context, key string) (err error) } func (fs *ocisfs) EmptyRecycle(ctx context.Context) error { + u, ok := user.ContextGetUser(ctx) // TODO what permission should we check? we could check the root node of the user? or the owner permissions on his home root node? - // The current impl will wipe your own trash. or when enable home is false the trash of the 'root' - if fs.o.EnableHome { - u := user.ContextMustGetUser(ctx) - // TODO use layout, see Tree.Delete() for problem - return os.RemoveAll(filepath.Join(fs.o.Root, "trash", u.Id.OpaqueId)) + // The current impl will wipe your own trash. or when no user provided the trash of 'root' + if !ok { + return os.RemoveAll(fs.getRecycleRoot(ctx)) } - return os.RemoveAll(fs.getRecycleRoot(ctx)) + + // TODO use layout, see Tree.Delete() for problem + return os.RemoveAll(filepath.Join(fs.o.Root, "trash", u.Id.OpaqueId)) } func getResourceType(isDir bool) provider.ResourceType {