Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

Johnetordoff
Copy link
Contributor

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

@Johnetordoff Johnetordoff changed the title [SVCS-294] Add rename validations [SVCS-294] Add rename validation Apr 17, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 76.593% when pulling f501339 on Johnetordoff:drop-box-slash-issue into b787a92 on CenterForOpenScience:develop.

@coveralls
Copy link

coveralls commented Oct 16, 2017

Coverage Status

Coverage decreased (-0.1%) to 88.889% when pulling 420c66d on Johnetordoff:drop-box-slash-issue into 481c9d9 on CenterForOpenScience:develop.

…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
@coveralls
Copy link

coveralls commented Nov 29, 2017

Coverage Status

Coverage decreased (-0.1%) to 89.798% when pulling e6edbe8 on Johnetordoff:drop-box-slash-issue into 26bf209 on CenterForOpenScience:develop.

@coveralls
Copy link

coveralls commented Jan 16, 2018

Coverage Status

Coverage decreased (-0.2%) to 89.818% when pulling 101378f on Johnetordoff:drop-box-slash-issue into 7958307 on CenterForOpenScience:develop.

Copy link
Contributor

@cslzchen cslzchen left a 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.

rename-failed

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.

@cslzchen cslzchen self-assigned this Jun 27, 2018
@@ -83,6 +83,8 @@ class BaseProvider(metaclass=abc.ABCMeta):
"""

BASE_URL = None
FORBIDDEN_FILENAME_CHARS = []
FORBIDDEN_FOLDERNAME_CHARS = ['/']
Copy link
Contributor

@NyanHelsing NyanHelsing Jul 16, 2018

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

@NyanHelsing
Copy link
Contributor

TODO: Double check this isn't supported, and clarify pr message a little bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants