Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trash-bin purge for ocis-storage #1399

Merged
merged 1 commit into from Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions 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
5 changes: 3 additions & 2 deletions internal/http/services/owncloud/ocdav/trashbin.go
Expand Up @@ -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)
})
}

Expand Down
13 changes: 7 additions & 6 deletions pkg/storage/fs/ocis/recycle.go
Expand Up @@ -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 {
Expand Down
13 changes: 5 additions & 8 deletions tests/acceptance/expected-failures-on-OCIS-storage.txt
Expand Up @@ -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
#
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt
Expand Up @@ -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
Expand Down
Expand Up @@ -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> DAV path
And user "Alice" has deleted file "<filename1>"
And user "Alice" has deleted file "<filename2>"
And as "Alice" file "<filename1>" should exist in the trashbin
And as "Alice" file "<filename2>" should exist in the trashbin
When user "Alice" empties the trashbin using the trashbin API
Then as "Alice" the file with original path "<filename1>" should exist in the trashbin
And as "Alice" the file with original path "<filename2>" 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
Expand Down