Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #981 - don't touch symlinks when preserveLastModified is true

  • Loading branch information...
commit 66317a6e514dc906a4b5d0a5b400d960afd0ed78 1 parent 964b7b4
@mrook mrook authored
View
2  classes/phing/util/FileUtils.php
@@ -142,7 +142,7 @@ function copyFile(PhingFile $sourceFile, PhingFile $destFile, $overwrite = false
}
}
- if ($preserveLastModified) {
+ if ($preserveLastModified && !$destFile->isLink()) {
$destFile->setLastModified($sourceFile->lastModified());
}
View
16 test/classes/phing/tasks/system/CopyTaskTest.php
@@ -51,5 +51,21 @@ public function testCopyDanglingSymlink()
$this->executeTarget("testCopyDanglingSymlink");
$this->assertInLogs("Copying 1 file to");
}
+
+ /**
+ * Test for {@link http://www.phing.info/trac/ticket/981}
+ * FileUtil::copyFile(): preserveLastModified causes
+ * empty symlink target file
+ */
+ public function testCopySymlinkPreserveLastModifiedShouldCopyTarget()
+ {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ $this->markTestSkipped("Bug not applicable on Window");
+ }
+
+ $this->executeTarget(__FUNCTION__);
+ $this->assertInLogs("Copying 2 files to");
+ $this->assertGreaterThan(0, $this->project->getProperty('test.filesize'));
+ }
}
View
16 test/etc/tasks/system/CopyTaskTest.xml
@@ -27,5 +27,21 @@
<delete dir="${tmp.dir}/new"/>
</target>
+ <target name="testCopySymlinkPreserveLastModifiedShouldCopyTarget">
+ <mkdir dir="${tmp.dir}/base"/>
+ <mkdir dir="${tmp.dir}/new"/>
+ <echo file="${tmp.dir}/base/x" message="Testmessage"/>
+ <symlink target="x" link="${tmp.dir}/base/y"/>
+
+ <copy todir="${tmp.dir}/new" preserveLastModified="true">
+ <filelist dir="${tmp.dir}/base" files="y,x"/>
+ </copy>
+
+ <filesize file="${tmp.dir}/new/x" propertyname="test.filesize"/>
+
+ <delete dir="${tmp.dir}/base"/>
+ <delete dir="${tmp.dir}/new"/>
+ </target>
+
<target name="main"/>
</project>
Please sign in to comment.
Something went wrong with that request. Please try again.