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 = null;
byte[] fileDigest = messageDigest.digest ();
StringBuffer checksum = new StringBuffer();
StringBuffer checksumSb = new StringBuffer();
for (int i = 0; i < fileDigest.length; i++) {
String hexStr = Integer.toHexString(0x00ff & fileDigest[i]);
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
Object destination = includeFileMap.get(src);
if (destination instanceof java.lang.String) {
@@ -375,7 +376,7 @@ public class Checksum extends MatchingTask implements Condition {
if (isCondition) {
checksumMatches = checksum.equals(property);
} else {
project.setProperty(prop, checksum.toString());
project.setProperty(prop, checksum);
}
} else if (destination instanceof java.io.File) {
if (isCondition) {
@@ -398,7 +399,7 @@ public class Checksum extends MatchingTask implements Condition {
} else {
File dest = (File) destination;
fos = new FileOutputStream(dest);
fos.write(checksum.toString().getBytes());
fos.write(checksum.getBytes());
fos.close();
fos = null;
}


Loading…
Cancel
Save