You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
DylanDonkersgoed
pushed a commit
to DylanDonkersgoed/flysystem-stream-wrapper
that referenced
this issue
Oct 23, 2020
I faced similar issue, what i did was just to put default stat
// Use the size of our handle, since it could have been written to or
// truncated.
$stream_util_size = StreamUtil::getSize($this->handle);if (!empty($stream_util_size)) {
// Only set size if stream_util_size is available or
// just send original file metadata.
$stat['size'] = $stat[7] = $stream_util_size;
}
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: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.
The text was updated successfully, but these errors were encountered: