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

Web workflow: use absolute paths to avoid paths being adjusted by current directory #9311

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Jun 6, 2024

The web workflow was using relative paths internally when adjusting paths at the root /. This made them subject to whatever os.chdir() had been set to. Instead, use absolute paths to avoid any influence by the current directory.

I tested by doing os.chdir("/lib") in the REPL while using the web workflow. Previously this messed up being able to descend into directories or fetch files. Now it seems to work fine.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Jun 6, 2024

@tannewt One confusion I had when tracking this down was what MP_VFS_ROOT meant, as returned by mp_vfs_lookup_path() in extmod/vfs.c. It seems to mean only /, and not the whole default filesystem. I'm thinking that even CIRCUITPY is a VFS that is mounted on MP_VFS_ROOT. So it seems MP_VFS_ROOT is only the / mount point, and not the filesystem itself. Do you remember the details here?

@RetiredWizard
Copy link

I only looked at the changes so I don't have the context for what the variables are, but the comments are talking about mount points and the issue seems to be more general as simple sub-directories exhibited the issue.

I did test the artifact and it resolved the problem demonstrated by the test code.py in the original issue, however now I don't think a file can be deleted using web workflow if the folder has been changed from the root folder using os.chdir.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Jun 6, 2024

Internally, the code is now using an absolute path instead of a relative path. That eliminates the current directory as something that influences path lookup. I'll look at the "delete" case: it may be taking a different path.

@RetiredWizard
Copy link

Ah, I guess I didn't check the delete before this update, it probably never worked. Rename isn't working either but Edit does....

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@tannewt
Copy link
Member

tannewt commented Jun 6, 2024

@tannewt One confusion I had when tracking this down was what MP_VFS_ROOT meant, as returned by mp_vfs_lookup_path() in extmod/vfs.c. It seems to mean only /, and not the whole default filesystem. I'm thinking that even CIRCUITPY is a VFS that is mounted on MP_VFS_ROOT. So it seems MP_VFS_ROOT is only the / mount point, and not the filesystem itself. Do you remember the details here?

I don't remember. Sorry!

@tannewt tannewt merged commit 76cc0a1 into adafruit:main Jun 6, 2024
207 checks passed
@dhalbert dhalbert deleted the web-workflow-use-abs-path branch June 6, 2024 19:19
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.

Web Workflow uploads file to wrong folder if default folder has been changed using os.chdir()
3 participants