@Override public boolean run(ClientContext context) { parent.fail(e); return true; }
} catch (Throwable e) { Logger.error(this, "Failed to decode "+this+" because of internal error: "+e, e); parent.fail(new FetchException(FetchExceptionMode.INTERNAL_ERROR, e)); } finally { chunk.release();
/** A segment ran out of retries. We have given up on that segment and therefore on the whole * splitfile. * @param segment The segment that failed. */ public void failOnSegment(SplitFileFetcherSegmentStorage segment) { fail(new FetchException(FetchExceptionMode.SPLITFILE_ERROR, errors)); }
private void maybeComplete() { if(allSucceeded()) { callSuccessOffThread(); } else if(allFinished() && !allSucceeded()) { // Some failed. fail(new FetchException(FetchExceptionMode.SPLITFILE_ERROR, errors)); } }
} else { parent.fail(new FetchException(FetchExceptionMode.SPLITFILE_DECODE_ERROR, "Decoded block does not match expected key")); return; } catch (CHKEncodeException e) { parent.fail(new FetchException(FetchExceptionMode.INTERNAL_ERROR, "Decoded block could not be encoded")); Logger.error(this, "Impossible: Decoded block could not be encoded"); return;
fail(new FetchException(FetchExceptionMode.SPLITFILE_ERROR, errors)); } else { if(completeViaTruncation) raf.close();
private boolean checkEncodedDataBlocks(byte[][] checkBlocks, boolean[] checkBlocksPresent, SplitFileSegmentKeys keys, boolean capturingBinaryBlob) { for(int i=0;i<checkBlocks.length;i++) { if(checkBlocksPresent[i]) continue; ClientCHK decodeKey = keys.getKey(i+blocksForDecode(), null, false); // Encode it to check whether the key is the same. ClientCHKBlock block; try { block = ClientCHKBlock.encodeSplitfileBlock(checkBlocks[i], decodeKey.getCryptoKey(), decodeKey.getCryptoAlgorithm()); ClientCHK actualKey = block.getClientKey(); if(!actualKey.equals(decodeKey)) { Logger.error(this, "Splitfile check block "+i+" does not encode to expected key for "+this+" for "+parent); return false; } if(capturingBinaryBlob) parent.fetcher.maybeAddToBinaryBlob(block); } catch (CHKEncodeException e) { // Impossible! parent.fail(new FetchException(FetchExceptionMode.INTERNAL_ERROR, "Decoded block could not be encoded")); Logger.error(this, "Impossible: Decoded block could not be encoded"); return false; } } return true; }
finished = true; parent.fail(new FetchException(FetchExceptionMode.SPLITFILE_DECODE_ERROR, "Encoded blocks do not match metadata")); return;
return false; } else { parent.fail(new FetchException(FetchExceptionMode.SPLITFILE_ERROR, "Splitfile block is too short")); return false;