Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MountFS fixes #487

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

Open
lurch wants to merge 1 commit into master
base: master
Choose a base branch
Loading
from mountfs_fixes
Open

MountFS fixes #487

lurch wants to merge 1 commit into master from mountfs_fixes

Conversation

Copy link
Contributor

@lurch lurch commented Jun 20, 2021

Type of changes

  • Bug fix
  • Tests

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @PyFilesystem/maintainers may be pedantic in the code review.

Description

Addresses issues outlined #486

  • Don't allow MountFS to have an empty mount-path
  • Don't allow files/dirs to be created inside MountFS's internal MemoryFS
  • Change MountFS's .mounts attribute to a dict instead of a list of tuples
  • Add a MountFS.unmount method
  • Add associated unit-tests

It's a long time since I've done any PyFilesystem development, so this should should be considered "WIP code", comments welcome... (e.g. I'm not sure if the unmount method is actually useful?)

This should be reviewed with care as the "bugfixes" this includes (the first two bullet-points above) subtly change the API of MountFS.

althonos reacted with thumbs up emoji
* Don't allow files/dirs to be created inside MountFS's internal MemoryFS
* Change MountFS's .mounts attribute to a dict instead of a list of tuples
* Add a MountFS.unmount method
* Add associated unit-tests
Copy link

Coverage Status

Coverage decreased (-0.02%) to 95.246% when pulling a99ccd2 on mountfs_fixes into 2d0ffc3 on master.

@althonos althonos self-assigned this Jun 27, 2021
Copy link
Member

@althonos althonos left a comment

Choose a reason for hiding this comment

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

Hi @lurch , thanks a lot for this, sorry it went under my radar! I think it looks fine apart from the one change I requested (it's probably me being paranoid/thinking too hard about edge cases).

self.auto_close = auto_close
self.default_fs = MemoryFS() # type: FS
self.mounts = [] # type: MutableSequence[Tuple[Text, FS]]
self.mounts = {} # type: Dict[Text, FS]
Copy link
Member

Choose a reason for hiding this comment

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

I think the reason a list was in use here was to preserve ordering of mounted files. Sure, a dict is fine for newer Python versions but I'd think this would change behaviour on Python 2.7. I think using collections.OrderedDict would work instead (and we can drop that when we move the code to PyFilesystem3).

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

Reviewers

@althonos althonos althonos requested changes

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /