Repository navigation
Fix Push sending a wrong DATA length after a short read - #140
Merged
Merged
Conversation
Push only rewrote the DATA header length when a read returned less than a full chunk, assuming that happens only at the end of the stream. A stream that returns a short read followed by a full one (pipes, network or COM streams) then sent the full chunk under the short read's length, and adbd aborted the transfer with "invalid data message". The length is now set from every read, in Push, PushAsync and the WinRT PushAsync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The size of a random access stream went into totalBytesRead instead of totalBytesToProcess, so progress started at the full size, ended at twice it, and never reported a total. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Are you sure AI is correctly? |
Contributor
Author
|
Well what happened is that I was implementing a direct streaming from Android to Windows using your library, instead of writing to a temp file and then giving it to Windows (streaming files using drag & drop / clipboard). Claude found this bug when trying the new mechanism with small files, and added tests that supposedly verify the fix. For now I switched to a fork that includes the fix. Naturally, don't take my word for it - feel free to decline the PR, but just to let you know that there might be a bug that needs to be fixed. The WinRT fix is untelated and not really required for my use case. |
Member
|
OK, I will merge this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two fixes in
SyncServicepush, one commit each.Wrong DATA length after a short read
Push/PushAsync(and the WinRTPushAsync) only rewrote the DATA header's length when a read returned less than a full chunk, assuming that only happens at the end of the stream. When a stream returns a short read and then a full one (pipes, network streams, COMIStreams), the full chunk goes out under the previous short read's length. adbd then aborts the transfer withinvalid data message, and the file is not written.FileStreamandMemoryStreamsources don't hit this, since their reads are only short at the end. I found it while streaming a pull from one device straight into a push to another through a pipe, and reproduced it on an Android 9 emulator and an Android 12 phone. The length is now set from every read.Test:
PushShortReadTest/PushShortReadAsyncTestpush from a stream that returns a 5-byte read followed by full ones; both fail without the fix.WinRT
PushAsyncprogressThe size of an
IRandomAccessStreamwas assigned tototalBytesReadinstead oftotalBytesToProcess, so progress started at the full size, ended at twice it, and never reported a total.PushWinRTAsyncTestnow checks the final progress, which failed before (1210 sent for a 605-byte file).🤖 Generated with Claude Code