// shard is getting closed on us
throw new IllegalBlobRecoveryStateException("Could not retrieve onGoingRecoveryStatus");
}
BlobRecoveryTransferStatus transferStatus = onGoingRecovery.onGoingTransfers().get(request.transferId());
BlobShard shard = onGoingRecovery.blobShard;
if (onGoingRecovery.canceled()) {
onGoingRecovery.sentCanceledToSource();
throw new IndexShardClosedException(onGoingRecovery.shardId());
}
if (transferStatus == null) {
throw new IndexShardClosedException(onGoingRecovery.shardId());
}
BytesReference content = request.content();
if (!content.hasArray()) {
content = content.toBytesArray();
}
transferStatus.outputStream().write(
content.array(), content.arrayOffset(), content.length()
);
if (request.isLast()) {
transferStatus.outputStream().close();
File source = new File(shard.blobContainer().getBaseDirectory(),
transferStatus.sourcePath()
);
File target = new File(shard.blobContainer().getBaseDirectory(),
transferStatus.targetPath()
);
if (target.exists()) {
logger.info("target file {} exists already.", target.getName());