@Override public void onSuccess(StreamGenerator streamGenerator, ClientMetadata clientMetadata, List<? extends Compressor> decompressors, ClientGetState state, ClientContext context) { context.uskManager.updateKnownGood(usk, usk.suggestedEdition, context); cb.onSuccess(streamGenerator, clientMetadata, decompressors, state, context); }
@Override public void onFailure(FetchException e, ClientGetState state, ClientContext context) { switch(e.mode) { case NOT_ENOUGH_PATH_COMPONENTS: case PERMANENT_REDIRECT: context.uskManager.updateKnownGood(origUSK, state.getToken(), context); return; } Logger.warning(this, "Found edition "+state.getToken()+" but failed to fetch edition: "+e, e); }
@Override public void onFailure(FetchException e, ClientGetState state, ClientContext context) { switch(e.mode) { case NOT_ENOUGH_PATH_COMPONENTS: case PERMANENT_REDIRECT: context.uskManager.updateKnownGood(usk, usk.suggestedEdition, context); } FreenetURI uri = e.newURI; if(uri != null) { // FIXME what are we doing here anyway? Document! uri = usk.turnMySSKIntoUSK(uri); e = new FetchException(e, uri); } cb.onFailure(e, state, context); }
@Override public synchronized void onSuccess(ClientPutState state, ClientContext context) { USK newEdition = pubUSK.copy(edition); finished = true; sbi = null; FreenetURI targetURI = pubUSK.getSSK(edition).getURI(); FreenetURI realURI = ((SingleBlockInserter)state).getURI(context); if(!targetURI.equals(realURI)) Logger.error(this, "URI should be "+targetURI+" actually is "+realURI); else { if(logMINOR) Logger.minor(this, "URI should be "+targetURI+" actually is "+realURI); context.uskManager.updateKnownGood(pubUSK, edition, context); } if(freeData) { data.free(); data = null; } cb.onEncode(newEdition, this, context); insertSucceeded(context, edition); // FINISHED!!!! Yay!!! }
public void checkUSK(FreenetURI uri, boolean persistent, boolean isMetadata) { try { FreenetURI uu; if(uri.isSSK() && uri.isSSKForUSK()) { uu = uri.setMetaString(null).uskForSSK(); } else if(uri.isUSK()) { uu = uri; } else { return; } USK usk = USK.create(uu); if(!isMetadata) context.uskManager.updateKnownGood(usk, uu.getSuggestedEdition(), context); else // We don't know whether the metadata is fetchable. // FIXME add a callback so if the rest of the request completes we updateKnownGood(). context.uskManager.updateSlot(usk, uu.getSuggestedEdition(), context); } catch (MalformedURLException e) { Logger.error(this, "Caught "+e, e); } catch (Throwable t) { // Don't let the USK hint cause us to not succeed on the block. Logger.error(this, "Caught "+t, t); } } }
context.uskManager.updateKnownGood(origUSK, state.getToken(), context); context.mainExecutor.execute(new PrioRunnable() {