Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81eca38

Browse filesBrowse files
committed
[Filesystem] Check number of bytes copied.
1 parent eb1e3c3 commit 81eca38
Copy full SHA for 81eca38

File tree

Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ public function copy($originFile, $targetFile, $override = false)
6060
throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
6161
}
6262

63-
stream_copy_to_stream($source, $target);
63+
$bytesCopied = stream_copy_to_stream($source, $target);
6464
fclose($source);
6565
fclose($target);
6666
unset($source, $target);
6767

6868
if (!is_file($targetFile)) {
6969
throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
7070
}
71+
72+
if (stream_is_local($originFile) && $bytesCopied !== filesize($originFile)) {
73+
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s %g bytes copied".', $originFile, $targetFile, $bytesCopied), 0, null, $originFile);
74+
}
7175
}
7276
}
7377

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.