/** Called when a ClientPutState transitions to a new state. If this is the current state, then we update * it, but it might also be a subsidiary state, in which case we ignore it. */ @Override public void onTransition(ClientPutState oldState, ClientPutState newState, ClientContext context) { if(newState == null) throw new NullPointerException(); synchronized (this) { if (currentState == oldState) { currentState = newState; return; } } if(persistent()) context.jobRunner.setCheckpointASAP(); Logger.normal(this, "onTransition: cur=" + currentState + ", old=" + oldState + ", new=" + newState); }
/** * Start an insert. Queue a database job if it is a persistent insert, otherwise start it right now. * @param inserter The insert to start. * @param earlyEncode Whether to try to encode the data and insert the upper layers as soon as possible. * Normally we wait for each layer to complete before inserting the next one because an attacker may be * able to identify lower blocks once the top block has been inserted (e.g. if it's a known SSK). * @throws InsertException If the insert is transient and it fails to start. * @throws DatabaseDisabledException If the insert is persistent and the database is disabled (e.g. * because it is encrypted and the user hasn't entered the password yet). */ public void start(final ClientPutter inserter) throws InsertException, PersistenceDisabledException { if(inserter.persistent()) { jobRunner.queue(new PersistentJob() { @Override public boolean run(ClientContext context) { try { inserter.start(false, context); } catch (InsertException e) { inserter.client.onFailure(e, inserter); } return true; } }, NativeThread.NORM_PRIORITY); } else { inserter.start(false, this); } }
boolean randomiseSplitfileKeys = randomiseSplitfileKeys(targetURI, ctx, persistent()); if(!binaryBlob) { ClientMetadata meta = cm; if(meta != null) meta = persistent() ? meta.clone() : meta; currentState = new SingleFileInserter(this, this, new InsertBlock(data, meta, targetURI), isMetadata, ctx, realTimeFlag, false, false, null, null, false, targetFilename, false, persistent(), 0, 0, null, cryptoAlgorithm, cryptoKey, metadataThreshold); } else currentState =