Fix cp/mv -I dropping all stdin paths after the first two - #1943
Open
gpshead wants to merge 1 commit into
Open
Conversation
Since 5.36, `gsutil cp -I` (and `mv -I`, which shares the code path) copies only the first two paths from stdin and exits 0, silently ignoring the rest. Regression from 13606f7 (Add Python 3.14 support), which wrapped combined_src_urls in list(itertools.chain(...)) because itertools objects are no longer picklable on 3.14. With -I, src_url_str is a one-shot StdinIteratorCls already handed to the NameExpansionIterator built a few lines earlier, whose plurality check buffers up to two entries. The list() call then drains the rest of stdin, so the copy loop only ever sees those two. combined_src_urls only feeds SeekAheadNameExpansionIterator, which RunCommand already skips for stdin sources, so skip populating it in that case and leave the stdin iterator alone. Add a unit test copying five files via -I; it fails on the previous code with only two copied. The existing integration test used two files, which the bug cannot drop. Fixes GoogleCloudPlatform#1908
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.
Since 5.36,
gsutil cp -I(andmv -I, which shares the code path) copies only the first two paths from stdin and exits 0, silently ignoring the rest.Regression from 13606f7 (Add Python 3.14 support), which wrapped combined_src_urls in list(itertools.chain(...)) because itertools objects are no longer picklable on 3.14. With -I, src_url_str is a one-shot StdinIteratorCls already handed to the NameExpansionIterator built a few lines earlier, whose plurality check buffers up to two entries. The list() call then drains the rest of stdin, so the copy loop only ever sees those two.
combined_src_urls only feeds SeekAheadNameExpansionIterator, which RunCommand already skips for stdin sources, so skip populating it in that case and leave the stdin iterator alone.
Add a unit test copying five files via -I; it fails on the previous code with only two copied. The existing integration test used two files, which the bug cannot drop.
Fixes #1908