ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r945023 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Checksum.java src/tests/antunit/taskdefs/checksum-test.xml
Date Mon, 17 May 2010 08:39:42 GMT
Author: bodewig
Date: Mon May 17 08:39:42 2010
New Revision: 945023

URL: http://svn.apache.org/viewvc?rev=945023&view=rev
Log:
<checksum>'s totalproperty doesn't work with repeated file names.  PR 36748

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
    ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=945023&r1=945022&r2=945023&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon May 17 08:39:42 2010
@@ -26,6 +26,10 @@ Fixed bugs:
  * <xslt> ignored the classpath when using the default TraX processor.
    Bugzilla Report 49271.
 
+ * <checksum>'s totalproperty only worked reliably if the same file
+   name didn't occur inside more than one directory.
+   Bugzilla Report 36748.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java?rev=945023&r1=945022&r2=945023&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java Mon May 17 08:39:42
2010
@@ -457,15 +457,7 @@ public class Checksum extends MatchingTa
         File directory;
         if (todir != null) {
             // A separate directory was explicitly declared
-            String path = (String) relativeFilePaths.get(file);
-            if (path == null) {
-                //bug 37386. this should not occur, but it has, once.
-                throw new BuildException(
-                    "Internal error: "
-                    + "relativeFilePaths could not match file"
-                    + file + "\n"
-                    + "please file a bug report on this");
-            }
+            String path = getRelativeFilePath(file);
             directory = new File(todir, path).getParentFile();
             // Create the directory, as it might not exist.
             directory.mkdirs();
@@ -559,8 +551,8 @@ public class Checksum extends MatchingTa
                             File f2 = (File) o2;
                             return f1 == null ? (f2 == null ? 0 : -1)
                                 : (f2 == null ? 1
-                                   : f1.getName().compareTo(f2.getName())
-                                   );
+                                   : getRelativeFilePath(f1)
+                                   .compareTo(getRelativeFilePath(f2)));
                         }
                     });
                 // Loop over the checksums and generate a total hash.
@@ -573,7 +565,7 @@ public class Checksum extends MatchingTa
                     messageDigest.update(digest);
 
                     // Add the file path
-                    String fileName = (String) relativeFilePaths.get(src);
+                    String fileName = getRelativeFilePath(src);
                     messageDigest.update(fileName.getBytes());
                 }
                 String totalChecksum = createDigestString(messageDigest.digest());
@@ -655,6 +647,21 @@ public class Checksum extends MatchingTa
     }
 
     /**
+     * @since Ant 1.8.2
+     */
+    private String getRelativeFilePath(File f) {
+        String path = (String) relativeFilePaths.get(f);
+        if (path == null) {
+            //bug 37386. this should not occur, but it has, once.
+            throw new BuildException("Internal error: "
+                                     + "relativeFilePaths could not match file "
+                                     + f + "\n"
+                                     + "please file a bug report on this");
+        }
+        return path;
+    }
+
+    /**
      * Helper class for the format attribute.
      *
      * @since 1.7

Modified: ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml?rev=945023&r1=945022&r2=945023&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/checksum-test.xml Mon May 17 08:39:42 2010
@@ -36,12 +36,13 @@
           https://issues.apache.org/bugzilla/show_bug.cgi?id=36748">
     <mkdir dir="${input}"/>
     <echo file="${input}/a.txt">abc</echo>
+    <echo file="${input}/subdir/A.txt">def</echo>
     <echo file="${input}/B.txt">xyz</echo>
     <checksum totalproperty="total">
       <fileset dir="${input}"/>
     </checksum>
     <au:assertPropertyEquals name="total"
-                             value="709a9cf15c8834c59c7eeb07522cdf56"/>
+                             value="f4d688789d32e6ca6bc93c504dbc6b46"/>
   </target>
 
 </project>



Mime
View raw message