Add ability to enable Read Sharing when Writing to files #370
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This change adds a new
LocalFileAbstraction.ReadShareWhenWriting
property. By default, this property isfalse
, resulting in no change in code flow. If a library user chooses to optionally enable it, then theWriteStream
created byLocalFileAbstraction
will useFileShare.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?