Skip to content

Commit

Permalink
adjusted behavior to always copy override on url files
Browse files Browse the repository at this point in the history
  • Loading branch information
cordoval committed Dec 30, 2013
1 parent c92274a commit 4fba412
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -41,7 +41,7 @@ public function copy($originFile, $targetFile, $override = false)

$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;
Expand Down
15 changes: 14 additions & 1 deletion src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -167,6 +167,19 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
$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
Expand Down Expand Up @@ -336,7 +349,7 @@ public function testRemoveCleansInvalidLinks()

mkdir($basePath);
mkdir($basePath.'dir');
// create symlink to unexisting file
// create symlink to nonexistent file
@symlink($basePath.'file', $basePath.'link');

$this->filesystem->remove($basePath);
Expand Down

0 comments on commit 4fba412

Please sign in to comment.