From 4fba412761121505f8bc622823caa58e40012f05 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Thu, 26 Dec 2013 06:42:47 -0500 Subject: [PATCH] adjusted behavior to always copy override on url files --- src/Symfony/Component/Filesystem/Filesystem.php | 2 +- .../Component/Filesystem/Tests/FilesystemTest.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index ecea0f0b81..d30dfd2c7a 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -41,7 +41,7 @@ class Filesystem $this->mkdir(dirname($targetFile)); - if (!$override && is_file($targetFile)) { + if (!$override && is_file($targetFile) && null == parse_url($originFile, PHP_URL_HOST)) { $doCopy = filemtime($originFile) > filemtime($targetFile); } else { $doCopy = true; diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 0e434c1045..5877e484c6 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -167,6 +167,19 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath)); } + public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToNotCopy() + { + $sourceFilePath = 'http://symfony.com/images/common/logo/logo_symfony_header.png'; + $targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file'; + + file_put_contents($targetFilePath, 'TARGET FILE'); + + $this->filesystem->copy($sourceFilePath, $targetFilePath, false); + + $this->assertFileExists($targetFilePath); + $this->assertEquals(file_get_contents($sourceFilePath), file_get_contents($targetFilePath)); + } + public function testMkdirCreatesDirectoriesRecursively() { $directory = $this->workspace @@ -336,7 +349,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase mkdir($basePath); mkdir($basePath.'dir'); - // create symlink to unexisting file + // create symlink to nonexistent file @symlink($basePath.'file', $basePath.'link'); $this->filesystem->remove($basePath);