From 6a3c7b926e1e87ff01ba7d3cdcdc43c4ec4677bf 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 --- .../unreleased/ocis-fix-trashbin-purge.md | 6 +++++ .../http/services/owncloud/ocdav/trashbin.go | 5 ++-- pkg/storage/fs/ocis/recycle.go | 13 ++++++----- .../expected-failures-on-OCIS-storage.txt | 13 ++++------- .../expected-failures-on-OWNCLOUD-storage.txt | 4 ---- .../apiTrashbin-trashbinDelete.feature | 23 ------------------- 6 files changed, 21 insertions(+), 43 deletions(-) create mode 100644 changelog/unreleased/ocis-fix-trashbin-purge.md diff --git a/changelog/unreleased/ocis-fix-trashbin-purge.md b/changelog/unreleased/ocis-fix-trashbin-purge.md new file mode 100644 index 0000000000..9be622b106 --- /dev/null +++ b/changelog/unreleased/ocis-fix-trashbin-purge.md @@ -0,0 +1,6 @@ +Bugfix: Fix ocis trash-bin purge + +Fixes the empty trash-bin functionality for ocis-storage + +https://github.com/cs3org/reva/pull/1399 +https://github.com/owncloud/product/issues/254 \ No newline at end of file diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index 6ebdd0deef..6bd980edc0 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 108186e43e..0fe2072189 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 { diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.txt b/tests/acceptance/expected-failures-on-OCIS-storage.txt index 1af68d981b..91191e3188 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.txt +++ b/tests/acceptance/expected-failures-on-OCIS-storage.txt @@ -721,14 +721,7 @@ apiShareReshareToShares3/reShareWithExpiryDate.feature:335 apiShareReshareToShares3/reShareWithExpiryDate.feature:336 apiShareReshareToShares3/reShareWithExpiryDate.feature:337 apiShareReshareToShares3/reShareWithExpiryDate.feature:338 -# -# https://github.com/owncloud/product/issues/254 empty trashbin does not work -# -apiTrashbin/trashbinDelete.feature:31 -apiTrashbin/trashbinDelete.feature:32 -apiTrashbin/trashbinDelete.feature:33 -apiTrashbin/trashbinDelete.feature:34 -apiTrashbin/trashbinDelete.feature:37 + # # https://github.com/owncloud/ocis/issues/1120 href in trashbin PROPFIND response is wrong # @@ -816,6 +809,10 @@ apiTrashbin/trashbinRestore.feature:312 apiTrashbin/trashbinRestore.feature:330 apiTrashbin/trashbinRestore.feature:331 # +# https://github.com/owncloud/product/issues/254 empty trashbin does not work +# +apiTrashbin/trashbinDelete.feature:37 +# # https://github.com/owncloud/ocis/issues/1123 deleting a received share-folder moves it to trash-bin but does not unshare it # apiTrashbin/trashbinSharingToShares.feature:24 diff --git a/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt b/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt index 5e882984ae..0a057c0892 100644 --- a/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt +++ b/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt @@ -791,10 +791,6 @@ apiShareReshareToShares3/reShareWithExpiryDate.feature:273 # https://github.com/owncloud/product/issues/254 empty trashbin does not work # https://github.com/owncloud/ocis/issues/551 delete from trashbin does not work # -apiTrashbin/trashbinDelete.feature:31 -apiTrashbin/trashbinDelete.feature:32 -apiTrashbin/trashbinDelete.feature:33 -apiTrashbin/trashbinDelete.feature:34 apiTrashbin/trashbinDelete.feature:37 apiTrashbin/trashbinDelete.feature:50 apiTrashbin/trashbinDelete.feature:67 diff --git a/tests/acceptance/features/apiOcisSpecific/apiTrashbin-trashbinDelete.feature b/tests/acceptance/features/apiOcisSpecific/apiTrashbin-trashbinDelete.feature index 1db04eb4d6..21cb15a6fb 100644 --- a/tests/acceptance/features/apiOcisSpecific/apiTrashbin-trashbinDelete.feature +++ b/tests/acceptance/features/apiOcisSpecific/apiTrashbin-trashbinDelete.feature @@ -13,29 +13,6 @@ Feature: files and folders can be deleted from the trashbin And user "Alice" has uploaded file with content "to delete" to "/PARENT/parent.txt" And user "Alice" has uploaded file with content "to delete" to "/PARENT/CHILD/child.txt" - @smokeTest - @issue-product-139 - @issue-product-178 - @issue-product-179 @skipOnOcis-OCIS-Storage - Scenario Outline: Trashbin cannot be emptied - # after fixing all issues delete this Scenario and use the one from oC10 core - Given user "Alice" has uploaded file with content "file with comma" to "sample,0.txt" - And user "Alice" has uploaded file with content "file with comma" to "sample,1.txt" - And using DAV path - And user "Alice" has deleted file "" - And user "Alice" has deleted file "" - And as "Alice" file "" should exist in the trashbin - And as "Alice" file "" should exist in the trashbin - When user "Alice" empties the trashbin using the trashbin API - Then as "Alice" the file with original path "" should exist in the trashbin - And as "Alice" the file with original path "" should exist in the trashbin - Examples: - | dav-path | filename1 | filename2 | - | old | textfile0.txt | textfile1.txt | - | old | sample,0.txt | sample,1.txt | - | new | textfile0.txt | textfile1.txt | - | new | sample,0.txt | sample,1.txt | - @smokeTest @issue-ocis-reva-118 @issue-product-179 @skipOnOcis-OCIS-Storage