From 0c726c8860418650ed86cec18d87f29902b2261c Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 12 May 2006 19:31:56 +0000 Subject: [PATCH] check file equality before deleting dest file in case of case-insensitive system case changing renames. Bugzilla 37701; submitted by Anthony Goubard. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@405846 13f79535-47bb-0310-9956-ffa450edef68 --- CONTRIBUTORS | 1 + WHATSNEW | 4 ++++ src/main/org/apache/tools/ant/taskdefs/Move.java | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 12fcf633b..dcf109346 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -6,6 +6,7 @@ Andreas Mross Andrew Everitt Anil K. Vijendran Anli Shundi +Anthony Goubard Anthony Green Antoine Levy-Lambert Anton Mazkovoi diff --git a/WHATSNEW b/WHATSNEW index f38b614f7..62c9e0a75 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -218,6 +218,10 @@ Fixed bugs: * and now correctly merge multiple nested patternsets. Bugzilla Report 38973. +* On case-insensitive filesystems, a to change filename case + erroneously deleted the "destination" file before attempting to rename + the source file. Bugzilla 37701. + Other changes: -------------- * took in bugzilla report 39320. diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java index 07d3dbf40..f76da561f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Move.java +++ b/src/main/org/apache/tools/ant/taskdefs/Move.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2005 The Apache Software Foundation + * Copyright 2000-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -373,7 +373,8 @@ public class Move extends Copy { if (parent != null && !parent.exists()) { parent.mkdirs(); } - if (destFile.isFile() && !destFile.delete()) { + if (destFile.isFile() && !destFile.equals(sourceFile) + && !destFile.delete()) { throw new BuildException("Unable to remove existing " + "file " + destFile); }