The new code copies the stream only if retries took place. Admittedly this also isn't optimal behavior - it would be better to return a new stream which prepends any previous streams (without seeking through the new stream). We should investigate the Stream classes being used to see if it's possible to do something like this.
Attempts to address https://github.com/googleapis/google-cloud-php/issues/7473 by not copying streams by default. This was copying the full streams even when the stream was only supposed to be opened.
The new code copies the stream only if retries took place. Admittedly this also isn't optimal behavior - it would be better to return a new stream which prepends any previous streams (without seeking through the new stream). We should investigate the Stream classes being used to see if it's possible to do something like this.