-
Notifications
You must be signed in to change notification settings - Fork 77
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
[SVCS-294] Add rename validation #213
base: develop
Are you sure you want to change the base?
[SVCS-294] Add rename validation #213
Conversation
…erbutler into drop-box-slash-issue * 'develop' of https://github.com/CenterForOpenScience/waterbutler: (77 commits) final cleanups for onedrive make provider readonly start cleaning up and reorganizing onedrive implement Microsoft OneDrive provider using dropbox as base added onedrive provider -- copied from Dropbox don't assume file metadata has a modified/created date add mypy type annotations add modified/created dates to file metadata expand docstrings add ruby serialization workaround to download clean up commit_sha vs. branch_name handling add tests for revisions and uninit-ed repos add artificial test for missing folder remove unused and obsolete code rewrite test suite for provider changes and coverage update some more docstrings on the provider GL provider is read-only: folder creation is not allowed add workaround for non-existent directories not being reported in GL document workarounds in download & _fetch_file_contents remove unneeded error wrapping from metadata ... # Conflicts: # waterbutler/server/api/v1/provider/movecopy.py
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.
For ⛺️ 🔥 :
I tried on OSFStorage (staging) and it failed with a different but misleading error message.
I think this is a general issue. The fix is not to allow those character but to catch exceptions and throw meaningful error messages. Fortunately, this PR fixes the issue at the core provider level 👍 . All we need to do is to check each provider and add the list FORBIDDEN_FILENAME_CHARS
accordingly. Last but not least, we need unit tests for this.
@@ -83,6 +83,8 @@ class BaseProvider(metaclass=abc.ABCMeta): | |||
""" | |||
|
|||
BASE_URL = None | |||
FORBIDDEN_FILENAME_CHARS = [] | |||
FORBIDDEN_FOLDERNAME_CHARS = ['/'] |
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.
Make this an abc property on the BaseProvider
TODO: Double check this isn't supported, and clarify pr message a little bit. |
Purpose
Currently you can rename a file or folder whatever you like, this creates a variety of error behaviors for the different providers. For Dropbox filenames with slashes create bad folders and files, for other providers the rename will just fail with no explanation, this fix alerts the user they are using an illegal character.
Changes
Add two static variables for the base provider FORBIDDEN_FILENAME_CHARS and FORBIDDEN_FOLDERNAME_CHARS which are used by validate_rename to bar the use of invalid characters.
Also cleans up some superfluous code in movecopy.py
Side Effects
None that I know of.
Tickets
https://openscience.atlassian.net/browse/SVCS-294