@Test public void testTemporaryCopies() throws IOException { DefaultBinaryManager binaryManager = new DefaultBinaryManager(); binaryManager.initialize("repo", Collections.emptyMap()); assertEquals(0, countFiles(binaryManager.getStorageDir())); FileBlob source = new FileBlob(new ByteArrayInputStream(CONTENT.getBytes("UTF-8"))); File originalFile = source.getFile(); binaryManager.storeAndDigest(source); assertFalse(originalFile.exists()); assertTrue(source.getFile().exists()); binaryManager.close(); }
protected String storeAndDigest(FileBlob blob) throws IOException { String digest; if (StringUtils.isEmpty(blob.getDigest())) { try (InputStream in = blob.getStream()) { digest = storeAndDigest(in, NullOutputStream.NULL_OUTPUT_STREAM); } } else { digest = blob.getDigest(); } File digestFile = getFileForDigest(digest, true); if (digestFile.exists()) { digestFile.setLastModified(blob.getFile().lastModified()); } else { blob.moveTo(digestFile); } return digest; }
DefaultBinaryManager extends LocalBinaryManager { protected String storeAndDigest(FileBlob blob) throws IOException { String digest; if (StringUtils.isEmpty(blob.getDigest())) { try (InputStream in = blob.getStream()) { digest = storeAndDigest(in, NullOutputStream.NULL_OUTPUT_STREAM); } } else { digest = blob.getDigest(); } File digestFile = getFileForDigest(digest, true); if (digestFile.exists()) { digestFile.setLastModified(blob.getFile().lastModified()); } else { blob.moveTo(digestFile); } return digest; } }
DefaultBinaryManager extends LocalBinaryManager { protected String storeAndDigest(FileBlob blob) throws IOException { String digest; if (StringUtils.isEmpty(blob.getDigest())) { try (InputStream in = blob.getStream()) { digest = storeAndDigest(in, NullOutputStream.NULL_OUTPUT_STREAM); } } else { digest = blob.getDigest(); } File digestFile = getFileForDigest(digest, true); if (digestFile.exists()) { digestFile.setLastModified(blob.getFile().lastModified()); } else { blob.moveTo(digestFile); } return digest; }  }
DefaultBinaryManager extends LocalBinaryManager { protected String storeAndDigest(FileBlob blob) throws IOException { String digest; if (StringUtils.isEmpty(blob.getDigest())) { try (InputStream in = blob.getStream()) { digest = storeAndDigest(in, NullOutputStream.NULL_OUTPUT_STREAM); } } else { digest = blob.getDigest(); } File digestFile = getFileForDigest(digest, true); if (digestFile.exists()) { digestFile.setLastModified(blob.getFile().lastModified()); } else { blob.moveTo(digestFile); } return digest; }  @Override Binary getBinary(Blob blob); }
DefaultBinaryManager extends LocalBinaryManager { protected String storeAndDigest(FileBlob blob) throws IOException { String digest; if (StringUtils.isEmpty(blob.getDigest())) { try (InputStream in = blob.getStream()) { digest = storeAndDigest(in, NullOutputStream.NULL_OUTPUT_STREAM); } } else { digest = blob.getDigest(); } File digestFile = getFileForDigest(digest, true); if (digestFile.exists()) { digestFile.setLastModified(blob.getFile().lastModified()); } else { blob.moveTo(digestFile); } return digest; }  @Override Binary getBinary(Blob blob);  }