Skip to content

Commit

Permalink
Add preference to optionally set Etag request header.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 19, 2010
1 parent 52ab01c commit d7f153a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions source/ch/cyberduck/core/Preferences.java
Expand Up @@ -521,6 +521,7 @@ protected void setDefaults() {
* If set calculate MD5 sum of uploaded file and set metadata header Content-MD5
*/
defaults.put("s3.upload.metadata.md5", String.valueOf(false));
defaults.put("cf.upload.metadata.md5", String.valueOf(false));
/**
* A prefix to apply to log file names
*/
Expand Down
21 changes: 15 additions & 6 deletions source/ch/cyberduck/core/cf/CFPath.java
Expand Up @@ -273,18 +273,27 @@ protected void upload(final BandwidthThrottle throttle, final StreamListener lis
// No Content-Range support
final Status status = this.status();
status.setResume(false);
String md5sum = null;
if(Preferences.instance().getBoolean("cf.upload.metadata.md5")) {
this.getSession().message(MessageFormat.format(Locale.localizedString("Compute MD5 hash of {0}", "Status"),
this.getName()));
md5sum = this.getLocal().attributes().getChecksum();
}
this.getSession().message(MessageFormat.format(Locale.localizedString("Uploading {0}", "Status"),
this.getName()));

final InputStream in;
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("MD5");
}
catch(NoSuchAlgorithmException e) {
log.error("MD5 calculation disabled:" + e.getMessage());
if(!Preferences.instance().getBoolean("cf.upload.metadata.md5")) {
try {
digest = MessageDigest.getInstance("MD5");
}
catch(NoSuchAlgorithmException e) {
log.error("MD5 calculation disabled:" + e.getMessage());
}
}
if(null == digest) {
log.warn("MD5 calculation disabled");
in = this.getLocal().getInputStream();
}
else {
Expand All @@ -303,7 +312,7 @@ public void writeRequest(OutputStream out) throws IOException {
CFPath.this.upload(out, in, throttle, listener);
}
},
metadata, null
metadata, md5sum
);
}
finally {
Expand Down

0 comments on commit d7f153a

Please sign in to comment.