@Override public Comparison compare(final Attributes remote, final Attributes local) { if(Checksum.NONE == remote.getChecksum()) { log.warn(String.format("No remote checksum available for comparison %s", remote)); return Comparison.unknown; } if(Checksum.NONE == local.getChecksum()) { log.warn(String.format("No local checksum available for comparison %s", local)); return Comparison.unknown; } if(remote.getChecksum().equals(local.getChecksum())) { return Comparison.equal; } return Comparison.notequal; } }
@Override protected void verify(final Path file, final MessageDigest digest, final Checksum checksum) throws ChecksumException { if(null == digest) { log.debug(String.format("Digest verification disabled for file %s", file)); return; } if(file.getType().contains(Path.Type.encrypted)) { log.warn(String.format("Skip checksum verification for %s with client side encryption enabled", file)); return; } final String expected = Hex.encodeHexString(digest.digest()); if(!checksum.equals(Checksum.parse(expected))) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", checksum.algorithm.toString(), expected, checksum.hash)); } }
protected void verify(final Path file, final MessageDigest digest, final Checksum checksum) throws ChecksumException { if(file.getType().contains(Path.Type.encrypted)) { log.warn(String.format("Skip checksum verification for %s with client side encryption enabled", file)); return; } if(null == digest) { log.debug(String.format("Digest disabled for file %s", file)); return; } if(null == checksum) { log.warn("ETag returned by server is unknown checksum algorithm"); return; } if(!checksum.algorithm.equals(HashAlgorithm.md5)) { log.warn(String.format("ETag %s returned by server is %s but expected MD5", checksum.hash, checksum.algorithm)); return; } // Obtain locally-calculated MD5 hash. final String expected = Hex.encodeHexString(digest.digest()); // Compare our locally-calculated hash with the ETag returned by S3. if(!checksum.equals(Checksum.parse(expected))) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server", expected, checksum.hash)); } }
return Worker.empty(); if(current.equals(checksum)) { if(log.isInfoEnabled()) { log.info(String.format("File %s not modified with checksum %s", local, current));
if(previous.equals(current)) { if(log.isInfoEnabled()) { log.info(String.format("Skip importing bookmarks from %s with previously saved checksum %s", file, previous));
if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum()));
if(Checksum.NONE != attributes.getChecksum()) { final ChecksumCompute compute = ChecksumComputeFactory.get(attributes.getChecksum().algorithm); if(compute.compute(local.getInputStream(), parent).equals(attributes.getChecksum())) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum()));
file.getName())); final Checksum download = compute.compute(local.getInputStream(), new TransferStatus()); if(!checksum.equals(download)) { throw new ChecksumException( MessageFormat.format(LocaleFactory.localizedString("Download {0} failed", "Error"), file.getName()),
if(!expected.equals(fingerprint)) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server",