Browse Source

fix the condition version of <checksum>

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270992 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
216965aa0f
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      src/main/org/apache/tools/ant/taskdefs/Checksum.java

+ 6
- 5
src/main/org/apache/tools/ant/taskdefs/Checksum.java View File

@@ -360,14 +360,15 @@ public class Checksum extends MatchingTask implements Condition {
fis.close(); fis.close();
fis = null; fis = null;
byte[] fileDigest = messageDigest.digest (); byte[] fileDigest = messageDigest.digest ();
StringBuffer checksum = new StringBuffer();
StringBuffer checksumSb = new StringBuffer();
for (int i = 0; i < fileDigest.length; i++) { for (int i = 0; i < fileDigest.length; i++) {
String hexStr = Integer.toHexString(0x00ff & fileDigest[i]); String hexStr = Integer.toHexString(0x00ff & fileDigest[i]);
if (hexStr.length() < 2) { if (hexStr.length() < 2) {
checksum.append("0");
checksumSb.append("0");
} }
checksum.append(hexStr);
checksumSb.append(hexStr);
} }
String checksum = checksumSb.toString();
//can either be a property name string or a file //can either be a property name string or a file
Object destination = includeFileMap.get(src); Object destination = includeFileMap.get(src);
if (destination instanceof java.lang.String) { if (destination instanceof java.lang.String) {
@@ -375,7 +376,7 @@ public class Checksum extends MatchingTask implements Condition {
if (isCondition) { if (isCondition) {
checksumMatches = checksum.equals(property); checksumMatches = checksum.equals(property);
} else { } else {
project.setProperty(prop, checksum.toString());
project.setProperty(prop, checksum);
} }
} else if (destination instanceof java.io.File) { } else if (destination instanceof java.io.File) {
if (isCondition) { if (isCondition) {
@@ -398,7 +399,7 @@ public class Checksum extends MatchingTask implements Condition {
} else { } else {
File dest = (File) destination; File dest = (File) destination;
fos = new FileOutputStream(dest); fos = new FileOutputStream(dest);
fos.write(checksum.toString().getBytes());
fos.write(checksum.getBytes());
fos.close(); fos.close();
fos = null; fos = null;
} }


Loading…
Cancel
Save