-
Notifications
You must be signed in to change notification settings - Fork 18
adding a bulk delete files method #153
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dbab2c4
adding a bulk delete files method
tcnichol e633903
changelog entry
tcnichol 73e712c
preparing to check permissions in FileService method
tcnichol 6547e76
adding check to see if user can delete file
tcnichol 116c296
checks if user can delete file
tcnichol 869e876
checks permission inside method
tcnichol 2923f8f
Merge branch 'develop' into bulk-delete-file-api
tcnichol a250cb4
using the new checkPermissions method for list of resource ref instea…
tcnichol d6beba4
removing redundant permissions check
tcnichol 6198cf4
matching develop
tcnichol e7eed03
adding swagger entry
tcnichol d8abe0b
Merge branch 'develop' into bulk-delete-file-api
tcnichol 16e387c
Merge branch 'develop' into bulk-delete-file-api
lmarini 8ce9c3b
Updated CHANGELOG.md.
lmarini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 action would let anyone logged in call this action and the
removeFilecall doesn't seem to reinforce permissions. We should use something likedef removeFile(id: UUID) = PermissionAction(Permission.DeleteFile, Some(ResourceRef(ResourceRef.file, id)))but I am not sure which permission to use since I don't believe we can pass in a list of resources.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.
Would another option be to files the FileService removeFile method to take permissions into account? It looks like it's supposed to do that, but just doesn't.
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 made a commit that does that.
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 implemented the ability to check a list of resources at once a while ago: https://github.com/clowder-framework/clowder/blob/develop/app/api/Permissions.scala#L282 I also added a bulk GET for a list of files: https://github.com/clowder-framework/clowder/blob/develop/app/services/FileService.scala#L104
You can use these in combination like this:
https://github.com/clowder-framework/clowder/blob/develop/app/util/SearchUtils.scala#L302
both of these calls return little objects that tell you what does/doesn't have permission and what was/wasn't found (if you asked for multiple files). Please use this pattern instead. The changes here, you added a new permission check inside the file service but existing uses of that call in api Files have already done the check so now it is checking twice.
If you remove the permission check in the service, and use the pattern above inside bulkDeleteFiles, it will use existing code and be a bit more efficient.
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.
@max-zilla thanks. that will be much better. i'll get this changed and push a new commit later today.
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 removed that check. Also merged develop into the branch.
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.
@tcnichol @max-zilla not sure about the changes to https://github.com/clowder-framework/clowder/blob/develop/app/services/mongodb/MongoDBFileService.scala#L818. I don't see are reference to permissions and the changes in the branch just look like spacing changes? Am I looking in the wrong place? Thank you.
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.
That commit is just spacing changes.
The actual change in checking permissions is in this file:
https://github.com/clowder-framework/clowder/pull/153/files'
line 1627 uses the new checkPermission method that takes in a list of resourceRef. I then removed any permission checks elsewhere.
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.
yeah, I saw the change to the controller, I understand that part. I am not sure I saw a change related to what @max-zilla said above regarding "Can you please also remove the permission check in 818 of MongoDB File Service as well, so we don't have redundant calls there." that's the file where there is white space changes, but nothing else?
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.
It looks like I removed the redundant check he mentioned a few commits ago on this one.