diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index fd2ec4bd72d3..3ac1f5a91cec 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -60,7 +60,7 @@ public function copy($originFile, $targetFile, $override = false) throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile); } - stream_copy_to_stream($source, $target); + $bytesCopied = stream_copy_to_stream($source, $target); fclose($source); fclose($target); unset($source, $target); @@ -68,6 +68,10 @@ public function copy($originFile, $targetFile, $override = false) if (!is_file($targetFile)) { throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile); } + + if (stream_is_local($originFile) && $bytesCopied !== filesize($originFile)) { + throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s %g bytes copied".', $originFile, $targetFile, $bytesCopied), 0, null, $originFile); + } } }