-
Notifications
You must be signed in to change notification settings - Fork 85
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
Position into the stream not reset #19
Comments
I think this behaviour is perfectly standard. Tools that consume a stream will move the stream position forward without moving it back.
This tool should not restore the stream position for two reasons.
1. The standard behaviour is already implemented.
2. Some streams do not support seeking. This case will lead to an exception being thrown inside the tools with no control from the developer.
It is your job as a user of any library to reposition your stream after you make a call that moves the stream cursor.
Note: This is my opinion as an experienced developer.
…________________________________
De : Aurélien Le Gonidec<mailto:[email protected]>
Envoyé : 19/05/2017 22:51
À : Muraad/Mime-Detective<mailto:[email protected]>
Cc : Subscribed<mailto:[email protected]>
Objet : [Muraad/Mime-Detective] Position into the stream not reset (#19)
When using GetFileType, the position into the stream is modified.
I had an issue trying to find out why my stream was suddenly considered as being 0 byte long, as after using FetFileType, I immediatly tried to upload it somewhere.
I suggest we could save the current position into the stream and update the position of the stream afterwords, when finishing copying the data from the stream :
in MimeType.cs
* line 214 : long currentPosition = stream.Position;
* line 224 : stream.Position = currentPosition;
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#19>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AATpTJyTh-Md64aZEA8YrienzyVhd42mks5r7gCigaJpZM4NhAFp>.
|
It seems logical to consider using a read or write function to change the position inside the stream. Using a method called GetType does not imply, in many people's mind, changing the state of the stream. I think it should be considered at least adding a comment. |
I would like to come back to my previous statement.
The actual implementation has 3 major flaws,
Now I think I will submit a PR to fix the flaws. I will be happy to continue the debate. I agree that a comment will be welcomed! |
@sandrock One of the first things I did in my fork was eliminate the unneeded temp file creation and access. It uses memory streams when needed for the same effect. Then I built a story around extension methods for handling inputs like streams, byte arrays, and File Info objects. |
When using GetFileType, the position into the stream is modified.
I had an issue trying to find out why my stream was suddenly considered as being 0 byte long, as after using FetFileType, I immediatly tried to upload it somewhere.
I suggest we could save the current position into the stream and update the position of the stream afterwords, when finishing copying the data from the stream :
in MimeType.cs
The text was updated successfully, but these errors were encountered: