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

Bug? - ZipArchive modifies underlying stream even if no archive changes made #34506

Closed
bgribaudo opened this issue Apr 3, 2020 · 1 comment · Fixed by #102704
Closed

Bug? - ZipArchive modifies underlying stream even if no archive changes made #34506

bgribaudo opened this issue Apr 3, 2020 · 1 comment · Fixed by #102704
Labels
area-System.IO.Compression help wanted [up-for-grabs] Good issue for external contributors in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@bgribaudo
Copy link
Contributor

bgribaudo commented Apr 3, 2020

If a ZipArchive instance is created with ZipArchiveMode.Update then disposed without being used to modify the archive, the underlying stream is still modified. If that underlying stream is a FileStream, this results in the associated file's modified timestamp being updated.

void Test() {
  using var stream = new FileStream("Test.zip", FileMode.Open, FileAccess.ReadWrite);
  using (var zip = new ZipArchive(stream, ZipArchiveMode.Update))
  {
     // do nothing
  } // even though the archive was unchanged from the user's perspective, stream is still updated, which changes Test.zip's modified timestamp
}

In contrast, FileStream does not exhibit this behavior. Simply opening a modifiable FileStream does not change the underlying file's modified timestamp.

Is how ZipArchive modifies its backing stream even when the archive is unmodified by the user a bug or a feature? :-)

What would be the chances of ZipArchive's manners being improved to avoid modifying its backing stream in this case?

Thanks!

-- dotnet version: 3.1.200

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.IO.Compression untriaged New issue has not been triaged by the area owner labels Apr 3, 2020
@ghost
Copy link

ghost commented Apr 3, 2020

Tagging @carlossanlop as an area owner

@carlossanlop carlossanlop added this to the Future milestone Jun 29, 2020
@carlossanlop carlossanlop removed the untriaged New issue has not been triaged by the area owner label Jul 8, 2020
@carlossanlop carlossanlop added the help wanted [up-for-grabs] Good issue for external contributors label May 26, 2023
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label May 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression help wanted [up-for-grabs] Good issue for external contributors in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants