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

Trim starting and trailing spaces while creating/uploading/renaming files and folders in the webUI #39310

Merged
merged 1 commit into from
Oct 1, 2021

Conversation

AlexAndBear
Copy link

@AlexAndBear AlexAndBear commented Sep 30, 2021

Description

Enhancement: Trim spaces while creating, uploading or renaming entities in webUI

With this change starting or trailing spaces will be removed while:

  • Creating files and folders in the webUI
  • Uploading files using the 'Upload' button in the webUI
  • Uploading files and folders using drag & drop in the webUI
  • Renaming files and folders in the webUI

This also solves problems when the sync client can't sync files and folders
with trailing spaces based on the underlying file system.

Related Issue

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@owncloud owncloud deleted a comment from ownclouders Sep 30, 2021
@owncloud owncloud deleted a comment from ownclouders Sep 30, 2021
@AlexAndBear AlexAndBear requested review from JammingBen and removed request for JammingBen September 30, 2021 13:19
@owncloud owncloud deleted a comment from update-docs bot Sep 30, 2021
@AlexAndBear AlexAndBear marked this pull request as ready for review September 30, 2021 13:22
@AlexAndBear AlexAndBear changed the title Trim spaces on creating or upload files and folders Trim starting and trailing spaces while creating/uploading/renaming files and folders in the webUI Sep 30, 2021
@owncloud owncloud deleted a comment from ownclouders Sep 30, 2021
@owncloud owncloud deleted a comment from ownclouders Sep 30, 2021
@owncloud owncloud deleted a comment from ownclouders Sep 30, 2021
@owncloud owncloud deleted a comment from ownclouders Sep 30, 2021
@sonarcloud
Copy link

sonarcloud bot commented Sep 30, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

73.1% 73.1% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me. I tried edge-cases like:

  • start with folders and sub-folders that have leading/trailing space in the name
  • try to upload files or folders into the root, or into any folder or sub-folder - they get trimmed of leading/trailing space
  • rename existing files/folders that have leading/trailing space, the space is trimmed off
  • try to rename an existing file folder to add leading/trailing space, the space is trimmed off
  • drag-and-drop to upload stuff - leading/trailing space is trimmed, including from any files/folders in the whole tree that is uploaded

@AlexAndBear
Copy link
Author

AlexAndBear commented Oct 1, 2021

@phil-davis nice, thx!
Do you have any edge cases in mind if it comes to replacing items aka conflict?

I know there is a bug while replacing a folder with the content of an empty folder, will likely do nothing -> so no files will be lost.
But this is a general bug, not provided by this PR and we need to discuss later, what is the expected behavior.

@phil-davis
Copy link
Contributor

Do you have any edge cases in mind if it comes to replacing items aka conflict?

It will be a bit odd if there is already a file or folder named like something (with a space at the end) and then you upload a file/folder called something (without the space). You will have both resources there. That will be an edge-case that does not automagically get rid of a space. But that is already existing behavior.

Other things that I have tried bring up the conflict dialog and ask what to do, and happily create names like something (2) etc.

Because any stripping of spaces gets applied from the web UI to the server, those will been seen as new changes and synced to other clients, which seems good and should work.

@AlexAndBear
Copy link
Author

AlexAndBear commented Oct 1, 2021

@phil-davis THX

That will be an edge-case that does not automagically get rid of a space. But that is already existing behavior.

Quite correct, but this should not be handled via UI IHMO, if we need it, we should write a migration that takes care of the files on storage

@phil-davis
Copy link
Contributor

phil-davis commented Oct 1, 2021

Quite correct, but this should not be handled via UI IHMO, if we need it, we should write a migration

IMO we don't need to bother having an automatic for any existing files with leading/trailing spaces.

It might be useful to have a command somewhere that scans user storage for files with leading/trailing spaces and trims them. An admin can choose to do that if they like, which will cleanup this all-at-once. That can be a separte PR, if someone wants it.

@AlexAndBear AlexAndBear merged commit 6fd4bc2 into master Oct 1, 2021
@delete-merged-branch delete-merged-branch bot deleted the enterprise/issues/4772 branch October 1, 2021 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spaces at the end and the beginning of a filename are trimmed away for display
4 participants