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

WithZipFile should open a read only handle(or have the option to) #573

Open
jswigart opened this issue Nov 6, 2022 · 2 comments
Open

WithZipFile should open a read only handle(or have the option to) #573

jswigart opened this issue Nov 6, 2022 · 2 comments
Labels
area:files Issue with FileModule and/or file providers bug good first issue Good starting point for new collaborators. pinned Pinned issues are not closed automatically when stale. v3.x v4.x

Comments

@jswigart
Copy link

jswigart commented Nov 6, 2022

Describe the bug
The built in WithZipFile extension method provides no mechanism for the user to open the zip file in read only mode, which is problematic if you have another instance of the map, or external tooling, also wanting to read the archive in read only mode.

To Reproduce
Steps to reproduce the behavior:

  1. Create an app that maps a module WithZipFile
  2. Run it multiple times, the 2nd will fail because the first has a write access lock on the file

Expected behavior
Expect to be able to open a zip file in read only mode. If the ZipFileProvider doesn't support writing at all, then the WithZipFile should just hard code to read only, as there is no reason for a write lock to be held.

Additional context
This was discussed a bit in slack for more information on October 24th, 2022

@rdeago rdeago added bug v3.x area:files Issue with FileModule and/or file providers v4.x pinned Pinned issues are not closed automatically when stale. labels Nov 6, 2022
@rdeago
Copy link
Collaborator

rdeago commented Nov 6, 2022

Hello @jswigart, thanks for opening this issue.

Non-literally quoting myself from Slack:

The zip file is opened with FileAccess.ReadWrite and FileShare.Read (the default):
https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.cs,120
We should use FileAccess.Read in the constructor call, as ReadWrite is not actualy needed.

There's no need for an option, as EmbedIO considers a Zip file an immutable file provider.

While we're on the subject, it wouldn't hurt to specify FileShare.Read explicitly too.

@rdeago rdeago added the good first issue Good starting point for new collaborators. label Nov 6, 2022
@rdeago
Copy link
Collaborator

rdeago commented Nov 6, 2022

This is the line to fix in version 3 (branch v3.x).

This is the line to fix in version 4 (branch master).

Any kind soul willing to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:files Issue with FileModule and/or file providers bug good first issue Good starting point for new collaborators. pinned Pinned issues are not closed automatically when stale. v3.x v4.x
Projects
None yet
Development

No branches or pull requests

2 participants