Skip to content

Commit

Permalink
Fix trash-bin purge (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
IljaN authored Jan 19, 2021
1 parent 3ebc86f commit fcd6626
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 43 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/ocis-fix-trashbin-purge.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit fcd6626

Please sign in to comment.