Browse Source

delete existing target files before copying - this avoids overwriting

symlinks and is consistent with Unix's cp(1).

PR: 624
Submitted by:	ederksen@arrow.lz.att.com (Enno Derksen)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269267 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
cc432705f2
2 changed files with 9 additions and 1 deletions
  1. +3
    -0
      WHATSNEW
  2. +6
    -1
      src/main/org/apache/tools/ant/Project.java

+ 3
- 0
WHATSNEW View File

@@ -139,6 +139,9 @@ Fixed bugs:
* <jjtree>'s uptodate test works even if outputdirectory is not the * <jjtree>'s uptodate test works even if outputdirectory is not the
parent dir of target parent dir of target


* <copy> will remove target file (if it exists) before writing to it -
this avoids problems with links on filesystems that support them.

Changes from Ant 1.2 to Ant 1.3 Changes from Ant 1.2 to Ant 1.3
=========================================== ===========================================




+ 6
- 1
src/main/org/apache/tools/ant/Project.java View File

@@ -752,8 +752,13 @@ public class Project {
boolean overwrite, boolean preserveLastModified) boolean overwrite, boolean preserveLastModified)
throws IOException { throws IOException {
if (overwrite ||
if (overwrite || !destFile.exists() ||
destFile.lastModified() < sourceFile.lastModified()) { destFile.lastModified() < sourceFile.lastModified()) {

if (destFile.exists()) {
destFile.delete();
}

log("Copy: " + sourceFile.getAbsolutePath() + " -> " log("Copy: " + sourceFile.getAbsolutePath() + " -> "
+ destFile.getAbsolutePath(), MSG_VERBOSE); + destFile.getAbsolutePath(), MSG_VERBOSE);




Loading…
Cancel
Save