-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
More helpful exception when compressing large files in seek mode #43542
Comments
@carlossanlop I am contributing after a long time and would like to attempt this. |
@WinCPP welcome back! I will assign this to you. Let us know if you need help. |
Thanks! And yes, I do need help 🙂 As per the documentation, the file to be added to an archive in update mode cannot be larger than
Here is the line that causes the exception (link). Digging more, I found this discussion about mscorlib code over here. that mentions that the max possible index for a byte array is |
Hi @WinCPP. I'm sorry we missed your question here. I agree with your assessment here that we should cap the size to |
Hi, @jeffhandley thanks for the reply. I am busy with some office work ATM. So I am fine if someone wants to take this ahead. |
Thanks, @WinCPP. And sorry again we missed your question earlier this year. |
When the user opens a stream in
Create
mode, and passes it to aZipArchive
opened inUpdate
mode, then attempts to add a very large file to the zip, an exception will be thrown on dispose statingStream was too long
, which is confusing for the user, and frustrating if the file was large and this happens so late.The exception is thrown because we restrict the size of a file to
Int32.MaxValue
. The restriction is reached because the Update mode requires a stream that allows seeking, so we internally create aMemoryStream
so that we can update the archive, but the size limit for the file isInt32.MaxValue
.We do have it documented here, but it's not very obvious for the user to look for answers in that location.
We should explore two improvements:
I also opened to suggest a Roslyn analyzer that would help users avoid falling into this: #35815
This has been reported a few times already:
/cc @ericstj
The text was updated successfully, but these errors were encountered: