Skip to content

Commit 021206c

Browse files
King2500fabpot
authored andcommitted
[Filesystem] Improve exception message for copy method
1 parent 4c767e6 commit 021206c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function copy($originFile, $targetFile, $override = false)
7272
// Like `cp`, preserve executable permission bits
7373
@chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
7474

75-
if (stream_is_local($originFile) && $bytesCopied !== filesize($originFile)) {
76-
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s %g bytes copied".', $originFile, $targetFile, $bytesCopied), 0, null, $originFile);
75+
if (stream_is_local($originFile) && $bytesCopied !== ($bytesOrigin = filesize($originFile))) {
76+
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile);
7777
}
7878
}
7979
}

0 commit comments

Comments
 (0)