public static MD5 digest(InputStream in) throws IOException { try { MessageDigest md; try { md = MessageDigest.getInstance("md5"); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException(e.toString()); } byte[] buffer = new byte[8192]; int read; while ((read = in.read(buffer)) > 0) { md.update(buffer, 0, read); } return new MD5(md.digest()); } finally { in.close(); } }
public MD5 md5() throws IOException { return MD5.digest(file); }
public void setMd5(MD5 md5) { if (this.md5 == null && md5 != null || this.md5 != null && !this.md5.equals(md5)) { this.md5 = md5; dirty = true; } }
protected void addAttributes(AttributesImpl attrs) { if (name != null) { attrs.addAttribute("", AN_NAME, "", "CDATA", name); } if (date > 0) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date); attrs.addAttribute("", AN_DATE, "", "CDATA", ISO8601.format(c)); } if (md5 != null) { attrs.addAttribute("", AN_MD5, "", "CDATA", md5.toString()); } if (contentType != null) { attrs.addAttribute("", AN_CONTENT_TYPE, "", "CDATA", contentType); } if (size > 0) { attrs.addAttribute("", AN_SIZE, "", "CDATA", String.valueOf(size)); } }
public static MD5 digest(File file) throws IOException { return digest(new FileInputStream(file)); }
entry.setMd5(new MD5(elem.getAttribute(AN_MD5))); } catch (Exception e) {
public boolean isSame(VltEntryInfo base) { return size == base.getSize() && ((md5 == null && base.getMd5() == null) || md5 != null && md5.equals(base.getMd5())); }
public void update(File file, boolean force) throws IOException { if (file.isDirectory()) { dirty = size != 0 && md5 != null && contentType != null; if (dirty) { size = 0; md5 = null; contentType = null; date = file.lastModified(); } } else { if (force || file.lastModified() != date || file.length() != size) { size = file.length(); md5 = MD5.digest(file); date = file.lastModified(); dirty = true; } } }
md5 = new MD5(digest.digest());
private boolean equalsToRemote(VaultFile remoteFile) throws VltException { MetaFile tmpFile = getTmpFile(); // copy file byte[] lineFeed = MimeTypes.isBinary(remoteFile.getContentType()) ? null : LineOutputStream.LS_NATIVE; VaultFileCopy copy; File temp = null; try { temp = tmpFile.openTempFile(); copy = VaultFileCopy.copy(remoteFile, temp, lineFeed); } catch (IOException e) { throw exception("Error while copying files.", e); } finally { if (tmpFile != null) { try { tmpFile.closeTempFile(true); } catch (IOException e) { // ignore } } } // if md5 is equal, no update VltEntryInfo base = entry.base(); return copy.getMd5().equals(base.getMd5()); }
public MD5 md5() throws IOException { InputStream in = parent.getZip().getInputStream(relPath); if (in == null) { throw new FileNotFoundException(parent.getFile() + ":" + relPath); } try { return MD5.digest(in); } finally { IOUtils.closeQuietly(in); } }
copy = VaultFileCopy.copy(remoteFile, temp, lineFeed); if (copy.getMd5().equals(base.getMd5())) { tmpFile.closeTempFile(tmpFile.length() >= 0); remoteUpdated = false; if (work.getMd5().equals(base.getMd5())) { if (oldMd5.equals(work.getMd5())) { action = FileAction.VOID; if (work.getMd5().equals(base.getMd5())) { base.setDate(work.getDate()); } else {