@@ -23,17 +23,17 @@ class Filesystem
23
23
/**
24
24
* Copies a file.
25
25
*
26
- * This method only copies the file if the origin file is newer than the target file.
26
+ * If the target file is older than the origin file, it's always overwritten.
27
+ * If the target file is newer, it is overwritten only when the
28
+ * $overwriteNewerFiles option is set to true.
27
29
*
28
- * By default, if the target already exists, it is not overridden.
29
- *
30
- * @param string $originFile The original filename
31
- * @param string $targetFile The target filename
32
- * @param bool $override Whether to override an existing file or not
30
+ * @param string $originFile The original filename
31
+ * @param string $targetFile The target filename
32
+ * @param bool $overwriteNewerFiles If true, target files newer than origin files are overwritten
33
33
*
34
34
* @throws IOException When copy fails
35
35
*/
36
- public function copy ($ originFile , $ targetFile , $ override = false )
36
+ public function copy ($ originFile , $ targetFile , $ overwriteNewerFiles = false )
37
37
{
38
38
if (stream_is_local ($ originFile ) && !is_file ($ originFile )) {
39
39
throw new IOException (sprintf ('Failed to copy %s because file not exists ' , $ originFile ));
@@ -42,7 +42,7 @@ public function copy($originFile, $targetFile, $override = false)
42
42
$ this ->mkdir (dirname ($ targetFile ));
43
43
44
44
$ doCopy = true ;
45
- if (!$ override && null === parse_url ($ originFile , PHP_URL_HOST ) && is_file ($ targetFile )) {
45
+ if (!$ overwriteNewerFiles && null === parse_url ($ originFile , PHP_URL_HOST ) && is_file ($ targetFile )) {
46
46
$ doCopy = filemtime ($ originFile ) > filemtime ($ targetFile );
47
47
}
48
48
0 commit comments