-
Notifications
You must be signed in to change notification settings - Fork 113
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 restore behavior of the trashbin API #1795
Conversation
The CI had some issues but I can't restart the build. |
@phil-davis, I think the tests in core for this are currently wrong IMO. Both backends, oC10 and with this PR oCIS too, delete the conflicting file, which then lands in the trashbin. I.e. effectively the two files change places and in the end there should still be a file with the What do you think? |
When this scenario was being run on oC10 it had 2 different behaviors and I could not sort out a test that would give a consistent result. Read issue owncloud/core#35974 - sometimes the restore from trashbin overwrites the existing file, and the existing file is found in the trashbin. That seems a reasonable behavior (but one could argue that the existing file should end up in the version history). But sometimes the existing file is not overwritten. The trashbin restore API request returns a "good" HTTP status, but actually the original file is still there, and actually the API request "did nothing". I will try enabling this again on oC10 and see if the variable results still happen. Then we need to decide what the system is supposed to do in this case. |
core PR owncloud/core#38869 has cleaned-up the scenario. |
Oh nice. I'll resolve that tomorrow. 👍 |
60f9342
to
76e63c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Well done getting a number of scenarios out of expected-failures.
if delRes.Status.Code != rpc.Code_CODE_OK && delRes.Status.Code != rpc.Code_CODE_NOT_FOUND { | ||
HandleErrorStatus(&sublog, w, delRes.Status) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this will handle the case where the restore wants to overwrite an existing resource, but the user does not have delete access to the resource.
And it might be more tricky if the user has change access to the resource, but not delete access. client.Delete
will probably refuse, but actually the end-effect that we want is to just overwrite. IMO this is also a hassle in oC10 - the back-end code has a similar flow where it deletes the resource first, then adds the restored resource. That kind of edge-case is something for a future PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, essentially restoring from the trash bin branches if:
- a resource in the restore destination exists and overwrite=T
- a resource in the restore destination exists and overwrite=F
- the restore destination is available
case 1 will delete the reference on dst
and call RestoreRecycleItem
case 2 will fail because the precondition does not pass: destination exists and overwrite is false (precondition = destination location is free)
case 3 will succeed as it is the opposite to case 2
looks good to me!
Just to add more into the fire, what about this scenario? I deleted /a/b/c/e.txt When restoring e.txt as a user I'd expect the hierarchy recreated and maybe asked about the possibility to choose where the restore will happen? original location and hierarchy recreated or another place? |
https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiTrashbin/trashbinRestore.feature currently has scenarios that use the API to restore I don't see scenarios for when the restore does not specify the target, and the original folder has been deleted. I should add scenarios for that, so that we at least know how oC10 behaves and can decide what to do! Issue owncloud/core#38882 - more test scenarios will come... But this PR is definitely a great step forward - lots of existing scenarios pass. |
ETag