return new Sftp(sftp, tmpDir);
}
@Override
public BlobData find(ByteString key) throws IOException {
RemoteFile remoteFile = buildRemoteFile(key);
File localCache;
try {
localCache = buildCacheFile(key, true);
} catch (IOException e) {
throw new IOException("Error creating local cache file", e);
}
if (localCache.exists()) {
// TODO: Verify?
log.debug("Using local cache file: {}", localCache);
} else {
try (TempFile localTemp = TempFile.in(this.localCacheDirTmp)) {
HashCode md5;
try (Sftp sftp = buildSftp(); InputStream is = sftp.open(remoteFile.getSshPath())) {
try (OutputStream os = new FileOutputStream(localTemp.getFile())) {
Hasher hasher = Hashing.md5().newHasher();
byte[] buffer = new byte[8192];
while (true) {
int n = is.read(buffer);