Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Filesystem | WCM] 9339 fix stat on url for filesystem copy#9899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsrc/Symfony/Component/Filesystem/Filesystem.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should benull === blablabla IIRC.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

true, sending the PR, thank you chief@stloyd

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$doCopy = filemtime($originFile) > filemtime($targetFile);
} else {
$doCopy = true;
Expand Down
15 changes: 14 additions & 1 deletionsrc/Symfony/Component/Filesystem/Tests/FilesystemTest.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmmm...assertStringEqualsFile() ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

1) Symfony\Component\Filesystem\Tests\FilesystemTest::testCopyForOriginUrlsAndExistingLocalFileDefaultsToNotCopyFailed asserting that file "http://symfony.com/images/common/logo/logo_symfony_header.png" exists./Users/cordoval/Sites/symfony-standard/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php:181

is not for files on the web

with

$this->assertStringEqualsFile($sourceFilePath, file_get_contents($targetFilePath));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

TBH. I'm not sure it's good to try to download files from remote servers anyway...

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

is not good, but there is not another way when testing this functionality, these and others are the slowest tests ever that make symfony test suite very slow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

IMO better approach would be like with i.e. Behat, start server on Travis-CI (Apache, nginx, whatever...) and give fixtures to be downloaded, it would be for sure more safe, and maybe even faster.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

great call, creating the ticket to be worked on

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

}

public function testMkdirCreatesDirectoriesRecursively()
{
$directory = $this->workspace
Expand DownExpand Up@@ -336,7 +349,7 @@ public function testRemoveCleansInvalidLinks()

mkdir($basePath);
mkdir($basePath.'dir');
// create symlink tounexisting file
// create symlink tononexistent file
@symlink($basePath.'file', $basePath.'link');

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

[8]ページ先頭

©2009-2025 Movatter.jp