Skip to content

OpenWrite doesn't prevent writing #1156

Description

@Benjamin-Berry

Describe the bug
Stream.CopyTpAsync still works with a write only stream.

To Reproduce
var fs = new MockFileSystem();

...

using var estream = entry.Open();
using var fstream = file.OpenWrite();
var temp = fstream.CanRead; // false
await fstream.CopyToAsync(estream);

Expected behavior
MockFileSystem and FileSystem would behave the same.

Additional context
I'm writing into a ZipArchive but that shouldn't matter.
Swapping to use FileSystem in the Unit test does throw a permissions exception.

Activity

  1. vbreuss commented on Oct 10, 2024

    @vbreuss
    Member

    @Benjamin-Berry :
    Could you please provide a complete repro example as it is unclear from your description what entry and file should be or what settings you applied.

  2. Benjamin-Berry commented on Oct 10, 2024

    @Benjamin-Berry
    Author

    I can't give you any proprietary code.

    var fs = new MockFileSystem();
    var directory = fs.DirectoryInfo.New("somepath");
    foreach (var file in directory.GetFiles(".", SearchOption.AllDirectories))
    {
    using var estream = new MemoryStream();
    using var fstream = file.OpenWrite();
    var temp = fstream.CanRead; // false
    await fstream.CopyToAsync(estream);
    }

  3. github-actions commented on Nov 8, 2024

    @github-actions

    This is addressed in release v21.1.2.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs discussionIssues that need further discussionstate: releasedIssues that are releasedtype: bugIssues that describe misbehaving functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions