Description
I encountered this issue with https://github.com/thephpleague/flysystem-azure-blob-storage/issues/22 but I believe it could occur for other remote filesystems.
When I attempt copy
with a remote file backed by flysystem-azure-blob-storage as the source it always writes 0 byte files at the destination. The culprit seems to be Twistor\FlysystemStreamWrapper::stream_stat() which sets the size of the returned $stat array to zero. This is because it calls Twistor\StreamUtil::getSize() which uses https://www.php.net/manual/en/function.fstat.php. There's a note on the documentation page:
Note: This function will not work on remote files as the file to be examined must be accessible via the server's filesystem.
I'm guessing that's why, though it fails in a much less obvious way than I'd expect from the note.
I'll attach a pull request shortly with a crude fix which ignores the fstat() filesize if it is zero and just uses the original file size from url_stat. I'm not sure if this is the best solution but it seems to work for me.