Skip to content

Add ability to enable Read Sharing when Writing to files #370

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eFail
Copy link

@eFail eFail commented Jun 6, 2025

What

This change adds a new LocalFileAbstraction.ReadShareWhenWriting property. By default, this property is false, resulting in no change in code flow. If a library user chooses to optionally enable it, then the WriteStream created by LocalFileAbstraction will use FileShare.Read, meaning that other processes can continue to read the file while it is being written to.

Currently, this change is only needed/useful when working with MP3 files. It will throw a NotSupportedException() if used anywhere else.

Why

A common scenario when editing ID3 tags is that a user uses one application (something like Mp3tag) to edit tags, while they use another application (something like WinAmp) to simultaneously listen to the MP3 files for which tags are being edited. This scenario works perfectly fine with most application mixes like the ones mentioned above. The only "side-effect" is a slight audio glitch that occurs after the tag of a playing song gets updated.

Using the example applications mentioned above, if Mp3tag were to be implemented using taglib-sharp, the above scenario no longer becomes possible. A user plays a song to determine what Genre it should be. Then, while they continue to listen to the song, they attempt to set the Genre in its ID3 tag. But they can't, because the MP3 file is already in use.

How Tested?

  • The scenario mentioned above didn't work before, now it does.
  • A new unit test was created to cover this new property.

@eFail
Copy link
Author

eFail commented Jun 6, 2025

@dotnet-policy-service agree

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.

1 participant