Skip to content

Fix path resolution #143

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 5 commits into from
Dec 4, 2024
Merged

Fix path resolution #143

merged 5 commits into from
Dec 4, 2024

Conversation

murilopolese
Copy link
Contributor

Problem

On windows, recursively upload of folders breaks and files are uploaded with leading \ and other characters.

While manual creation of folders and uploads of files within newly created folders works, if the user tries to upload a whole folder, the recursive process creates the folder at destination, as per createFolder action, but the files within the folders are uploaded with an unsanitized path, containing Windows' back-slash, hence “creating” a file with a name containing a “broken” path.

Slashes should be sanitized when it comes to destination path.

How to reproduce

On your local filesystem create a folder named test_folder

Enter this folder and create 2 files:

  • test1.py
  • test2.py

The files can be empty

Connect your board, select the folder and “upload” it as a whole.

Solution

Making sure relative path won't contain initial separator.

image

Making sure relative path won't contain initial separator
@@ -1509,7 +1509,7 @@ async function uploadFolder(srcPath, destPath, dataConsumer) {
let allFiles = await disk.ilistAllFiles(srcPath)
for (let i in allFiles) {
const file = allFiles[i]
const relativePath = file.path.substring(srcPath.length)
const relativePath = file.path.substring(srcPath.length+1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this change does not seem to affect the process of uploading recursively. I have tested both and saw no changes in the final outcome.
also here you added 1 and at line 1526 removed the slicing.
not sure what this addresses

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is obsolete after your merged patch. This would remove a separator from the beginning of a relative path.

@murilopolese murilopolese requested a review from ubidefeo December 4, 2024 06:59
Copy link
Collaborator

@ubidefeo ubidefeo left a comment

Choose a reason for hiding this comment

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

LGTM

@murilopolese murilopolese merged commit 098b935 into development Dec 4, 2024
1 check passed
@murilopolese murilopolese deleted the bugfix/recursive-upload branch December 4, 2024 07:10
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.

2 participants