-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Let occ trashbin:restore
restore also from groupfolders and add filters
#39818
Conversation
627a517
to
d2581e5
Compare
CI errors seems unrelated |
occ trashbin:restore
restore also from groupfolders and add filters
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.
Nice improvement of the command
Did you test the command with groupfolders application not installed? |
First of all thanks for your thorough review. Will try to incorporate the changes ASAP. Indeed I did not yet test it without the Groupfolders app installed but since there's no direct reference to it, it should work. I can do that after I've improved the code 👍 EDIT Code improved and also tested without Groupfolders app. Works fine |
@R0Wi sorry but can you just insert in the 1st post the result of commands but with GF disabled, like:
Thanks 👍 |
@solracsf please find the test-script attached. Note that no groupfolders app was installed. devcontainer@a9176d865258:/var/www/html$ php occ app:list 2>/dev/null
Enabled:
- cloud_federation_api: 1.11.0
- comments: 1.18.0
- contactsinteraction: 1.9.0
- dashboard: 7.8.0
- dav: 1.28.0
- federatedfilesharing: 1.18.0
- federation: 1.18.0
- files: 1.23.0
- files_reminders: 1.0.0
- files_sharing: 1.20.0
- files_trashbin: 1.18.0
- files_versions: 1.21.0
- lookup_server_connector: 1.16.0
- oauth2: 1.16.2
- provisioning_api: 1.18.0
- settings: 1.10.0
- sharebymail: 1.18.0
- systemtags: 1.18.0
- theming: 2.3.0
- twofactor_backupcodes: 1.17.0
- updatenotification: 1.18.0
- user_status: 1.8.0
- weather_status: 1.8.0
- workflowengine: 2.10.0
Disabled:
- admin_audit: 1.18.0
- encryption: 2.16.0
- files_external: 1.20.0
- testing: 1.18.0
- user_ldap: 1.19.0
devcontainer@a9176d865258:/var/www/html$ php occ trashbin:restore --dry-run --all-users --scope groupfolders -v 2>/dev/null
Restoring deleted files for all users
Restoring deleted files for users on backend Database
admin
Skipping welcome.txt because it is not a groupfolders trash item
User has no deleted files in the trashbin matching the given filters
devcontainer@a9176d865258:/var/www/html$ php occ trashbin:restore --dry-run --all-users --scope all 2>/dev/null
Restoring deleted files for all users
Restoring deleted files for users on backend Database
admin
Would restore 1 files...
Would restore welcome.txt originally deleted at 14. August 2023, 10:43:41 UTC to /welcome.txt
devcontainer@a9176d865258:/var/www/html$ php occ trashbin:restore --dry-run --all-users --scope user -v 2>/dev/null
Restoring deleted files for all users
Restoring deleted files for users on backend Database
admin
Would restore 1 files...
Would restore welcome.txt originally deleted at 14. August 2023, 10:43:41 UTC to /welcome.txt
devcontainer@a9176d865258:/var/www/html$ php occ trashbin:restore --dry-run --all-users --scope all --since "12.08.2023 13:04:44" --until "12.08.2023 13:04:46" -v 2>/dev/null
Restoring deleted files for all users
Restoring deleted files for users on backend Database
admin
Skipping welcome.txt because it was deleted after the 'until' timestamp
User has no deleted files in the trashbin matching the given filters Note that I adjusted the verbose output of the last command to match the new parameter names in 66c88cc |
…ional filters * Using the TrashManager allows access to all deleted files * Add 'scope' parameter to choose where to restore from (user or groupfolders) * Add 'restore-from' and 'restore-to' date parameters to filter files to be restored by their deletion date * Add 'dry-run' flag to be able to see which files would be restored and being able to adjust the filter parameters accordingly Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
* Delete unnecessary function docs * Rename parameters to 'since' and 'until' * Style: use '&&' instead of 'and' * Add types Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
66c88cc
to
d7a73ff
Compare
Just waiting from reviews from core developpers :) |
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.
Looks good overall.
From what I read, it should work if groudfolders is not installed. Can you confirm that?
// We use getTitle() here instead of getOriginalLocation() because | ||
// for groupfolders this contains the groupfolder name itself as prefix | ||
// which makes it more human readable | ||
$location = $trashItem->getTitle(); |
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.
The goal is to display the groupfolder name ? Could the following work?
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$userFolder->get($trashItem->getOriginalLocation())->getMountPoint()->getInternalPath();
That's correct. I tested both situations where the |
@artonge I don't want to put too much preasure on this but any additional feedback would be really appreciated. My customer would be highly interested in this new feature. Thanks 👍 |
@come-nc anything to add from your side? |
I’m still uneasy about this |
@R0Wi I'll let you merge if everything is good on your side :) |
/backport to stable27 |
Resolves: #39724
Summary
Let
occ trashbin:restore
restore also from groupfolders and add additional filtersrestored by their deletion date
able to adjust the filter parameters accordingly
Manual testcases
Showcase
Assume we have two files in our trashbin. One is
Userfile.txt
which was deleted from a users private directory. The other one isGroupfoldersFile.jpg
which was deleted from a groupfoldergf1
where useradmin
(which we use for restore) has access to.TODO
ITrashBackend
which would be found by theTrashManager
: are there any of them and if yes, how to deal with them?Checklist