Package freenet.support.io

Examples of freenet.support.io.ResumeFailedException


            this.completionTime = completionTime;
            if(returnType == ReturnType.NONE) {
                // OK.
            } else if(returnType == ReturnType.DISK) {
                if(!(targetFile.exists() && targetFile.length() == foundDataLength))
                    throw new ResumeFailedException("Success but target file doesn't exist or isn't valid");
            } else if(returnType == ReturnType.DIRECT) {
                returnBucketDirect = data;
                if(returnBucketDirect.size() != foundDataLength)
                    throw new ResumeFailedException("Success but temporary data bucket doesn't exist or isn't valid");
            }
        }
    }
View Full Code Here


                    currentState.onResume(context);
                if(origSFI != null)
                    origSFI.onResume(context);
            } catch (InsertException e) {
                Logger.error(this, "Failed to start insert on resume: "+e, e);
                throw new ResumeFailedException("Insert error: "+e);
            }
        }
View Full Code Here

        Logger.normal(this, "Resuming splitfile download for "+this);
        boolean completeViaTruncation = dis.readBoolean();
        if(completeViaTruncation) {
            fileCompleteViaTruncation = new File(dis.readUTF());
            if(!fileCompleteViaTruncation.exists())
                throw new ResumeFailedException("Storage file does not exist: "+fileCompleteViaTruncation);
            callbackCompleteViaTruncation = (FileGetCompletionCallback) getter;
            long rafSize = dis.readLong();
            if(fileCompleteViaTruncation.length() != rafSize)
                throw new ResumeFailedException("Storage file is not of the correct length");
            // FIXME check against finalLength too, maybe we can finish straight away.
            this.raf = new PooledFileRandomAccessBuffer(fileCompleteViaTruncation, false, rafSize, null, -1, true);
        } else {
            this.raf = BucketTools.restoreRAFFrom(dis, context.persistentFG, context.persistentFileTracker, context.getPersistentMasterSecret());
            fileCompleteViaTruncation = null;
View Full Code Here

        underlyingBuffer.onResume(context);
        try {
            setup(context.getPersistentMasterSecret(), false);
        } catch (IOException e) {
            Logger.error(this, "Disk I/O error resuming: "+e, e);
            throw new ResumeFailedException(e);
        } catch (GeneralSecurityException e) {
            Logger.error(this, "Impossible security error resuming - maybe we lost a codec?: "+e, e);
            throw new ResumeFailedException(e);
        }
    }
View Full Code Here

        LockableRandomAccessBuffer underlying = BucketTools.restoreRAFFrom(dis, fg, persistentFileTracker, masterKey);
        try {
            return new EncryptedRandomAccessBuffer(type, underlying, masterKey, false);
        } catch (GeneralSecurityException e) {
            Logger.error(EncryptedRandomAccessBuffer.class, "Crypto error resuming: "+e, e);
            throw new ResumeFailedException(e);
        }
    }
View Full Code Here

            throw new StorageFormatException("Bad splitfile codec type");
        }
        this.dataLength = dis.readLong();
        if(dataLength <= 0) throw new StorageFormatException("Bad data length");
        if(dataLength != originalData.size())
            throw new ResumeFailedException("Original data size is "+originalData.size()+" should be "+dataLength);
        if(((dataLength + CHKBlock.DATA_LENGTH - 1) / CHKBlock.DATA_LENGTH) != totalDataBlocks)
            throw new StorageFormatException("Data blocks "+totalDataBlocks+" not compatible with size "+dataLength);
        decompressedLength = dis.readLong();
        if(decompressedLength <= 0)
            throw new StorageFormatException("Bogus decompressed length");
View Full Code Here

            try {
                currentState.onResume(context);
            } catch (FetchException e) {
                currentState = null;
                Logger.error(this, "Failed to resume: "+e, e);
                throw new ResumeFailedException(e);
            } catch (RuntimeException e) {
                // Severe serialization problems, lost a class silently etc.
                Logger.error(this, "Failed to resume: "+e, e);
                throw new ResumeFailedException(e);
            }
        // returnBucket is responsibility of the callback.
        notifyClients(context);
    }
View Full Code Here

  /** Redirect target */
  private FreenetURI targetURI;
 
    public freenet.support.api.ManifestElement migrate(BucketFactory bf, ClientContext context) throws ResumeFailedException, IOException {
        if(data == null) {
            if(targetURI == null) throw new ResumeFailedException("Must have either a URI or a redirect");
            return new freenet.support.api.ManifestElement(name, fullName, mimeOverride, targetURI);
        } else {
            if(data.size() != dataSize) throw new ResumeFailedException("Bucket in site insert changed size from "+dataSize+" to "+data.size());
            data.onResume(context);
            RandomAccessBucket convertedData = BucketTools.toRandomAccessBucket(data, bf);
            return new freenet.support.api.ManifestElement(name, fullName, convertedData, mimeOverride, dataSize);
        }
  }
View Full Code Here

    }
   
    public EncryptedRandomAccessBucket(DataInputStream dis, FilenameGenerator fg,
            PersistentFileTracker persistentFileTracker, MasterSecret masterKey2) throws IOException, ResumeFailedException, StorageFormatException {
        type = EncryptedRandomAccessBufferType.getByBitmask(dis.readInt());
        if(type == null) throw new ResumeFailedException("Unknown EncryptedRandomAccessBucket type");
        underlying = (RandomAccessBucket) BucketTools.restoreFrom(dis, fg, persistentFileTracker, masterKey2);
        this.baseSetup(masterKey2);
    }
View Full Code Here

                container.activate(compatMessage, Integer.MAX_VALUE);
                SplitfileCompatibilityModeEvent e = compatMessage.toEvent();
                ret.receive(e, context);
            }
            if(succeeded) {
                if(foundDataLength <= 0) throw new ResumeFailedException("No data");
                Bucket data = null;
                if(returnType == RETURN_TYPE_DIRECT) {
                    container.activate(allDataPending, Integer.MAX_VALUE);
                    data = allDataPending.bucket;
                    if(data == null) throw new ResumeFailedException("No data");
                    data.onResume(context);
                }
                ret.setSuccessForMigration(context, completionTime, data);
            } else if(this.getFailedMessage != null) {
                ret.onFailure(getFailedMessage.getFetchException(), null);
View Full Code Here

TOP

Related Classes of freenet.support.io.ResumeFailedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.