Skip to content

Fix cp/mv -I dropping all stdin paths after the first two - #1943

Open
gpshead wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
gpshead:fix-cp-stdin-drops-paths
Open

Fix cp/mv -I dropping all stdin paths after the first two#1943
gpshead wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
gpshead:fix-cp-stdin-drops-paths

Conversation

@gpshead

@gpshead gpshead commented Aug 18, 2026

Copy link
Copy Markdown

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 #1908

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug (5.36): gsutil cp -I copies only the first two files

1 participant