Package freenet.support.io

Examples of freenet.support.io.FileBucket


    return mime;
  }

  @Override
  public RandomAccessBucket getData() {
    return new FileBucket(file, true, false, false, false);
  }
View Full Code Here


      } catch (IOException e) {
        throw new FetchException(FetchExceptionMode.BUCKET_ERROR, "Cannot create temp file for "+filename+" in "+parent+" - disk full? permissions problem?");
      }
      getter = new ClientGetter(this, 
          chk, myCtx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
          new FileBucket(tempFile, false, false, false, false), null, null);
      myCtx.eventProducer.addEventListener(this);
      this.cb = cb;
      this.filename = filename;
      this.expectedHash = expectedHash;
      this.expectedLength = expectedLength;
View Full Code Here

    ctx = core.makeClient((short) 1, true, false).getFetchContext();
    ctx.allowSplitfiles = true;
    ctx.dontEnterImplicitArchives = false;
    ctx.maxNonSplitfileRetries = -1;
    ctx.maxSplitfileBlockRetries = -1;
    blobBucket = new FileBucket(saveTo, false, false, false, false);
    if(blobBucket.size() > 0) {
      fetched = true;
      cg = null;
      tempFile = null;
    } else {
      // Write to temp file then rename.
      // We do not want to rename unless we are sure we've finished the fetch.
      File tmp;
      try {
        tmp = File.createTempFile(saveTo.getName(), NodeUpdateManager.TEMP_BLOB_SUFFIX, saveTo.getParentFile());
        tmp.deleteOnExit(); // To be used sparingly, as it leaks, but safe enough here as it should only happen twice during a normal run.
      } catch (IOException e) {
        Logger.error(this, "Cannot create temp file so cannot fetch legacy jar "+uri+" : UOM from old versions will not work!");
        cg = null;
        fetched = false;
        tempFile = null;
        return;
      }
      tempFile = tmp;
      cg = new ClientGetter(this, 
          uri, ctx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
          null, new BinaryBlobWriter(new FileBucket(tempFile, false, false, false, false)));
      fetched = false;
    }
  }
View Full Code Here

  public void start(boolean aggressive) {
    start(aggressive, true);
    if(blobFile.exists()) {
      ArrayBucket bucket = new ArrayBucket();
      try {
        BucketTools.copy(new FileBucket(blobFile, true, false, false, true), bucket);
        // Allow to free if bogus.
        manager.uom.processRevocationBlob(bucket, "disk", true);
      } catch (IOException e) {
        Logger.error(this, "Failed to read old revocation blob: "+e, e);
        System.err.println("We may have downloaded an old revocation blob before restarting but it cannot be read: "+e);
View Full Code Here

          if(FileUtil.getCanonicalFile(f).equals(FileUtil.getCanonicalFile(blobFile))) return;
        }
      }
      System.out.println("Unexpected blob file in revocation checker: "+tmpBlob);
    }
    FileBucket fb = new FileBucket(blobFile, false, false, false, false);
    try {
      BucketTools.copy(tmpBlob, fb);
    } catch (IOException e) {
      System.err.println("Got revocation but cannot write it to disk: "+e);
      System.err.println("This means the auto-update system is blown but we can't tell other nodes about it!");
View Full Code Here

      if(blobBucket != null)
        return blobBucket;
    }
    File f = getBlobFile();
    if(f == null) return null;
    return new FileBucket(f, true, false, false, false);
  }
View Full Code Here

    public void testStoreTo() throws IOException, StorageFormatException, ResumeFailedException, GeneralSecurityException {
        File tempFile = File.createTempFile("test-storeto", ".tmp", base);
        byte[] buf = new byte[4096];
        Random r = new Random(1267612);
        r.nextBytes(buf);
        FileBucket fb = new FileBucket(tempFile, false, false, false, true);
        EncryptedRandomAccessBucket erab = new EncryptedRandomAccessBucket(types[0], fb, secret);
        OutputStream os = erab.getOutputStream();
        os.write(buf, 0, buf.length);
        os.close();
        InputStream is = erab.getInputStream();
View Full Code Here

    public void testSerialize() throws IOException, StorageFormatException, ResumeFailedException, GeneralSecurityException, ClassNotFoundException {
        File tempFile = File.createTempFile("test-storeto", ".tmp", base);
        byte[] buf = new byte[4096];
        Random r = new Random(1267612);
        r.nextBytes(buf);
        FileBucket fb = new FileBucket(tempFile, false, false, false, true);
        EncryptedRandomAccessBucket erab = new EncryptedRandomAccessBucket(types[0], fb, secret);
        OutputStream os = erab.getOutputStream();
        os.write(buf, 0, buf.length);
        os.close();
        InputStream is = erab.getInputStream();
View Full Code Here

            @Override
            public boolean run(ClientContext context) {
              final ClientPut clientPut;
              try {
              try {
                clientPut = new ClientPut(fcp.getGlobalForeverClient(), furi, identifier, Integer.MAX_VALUE, null, RequestStarter.BULK_SPLITFILE_PRIORITY_CLASS, Persistence.FOREVER, null, false, !compress, -1, UploadFrom.DISK, file, contentType, new FileBucket(file, true, false, false, false), null, target, false, false, Node.FORK_ON_CACHEABLE_DEFAULT, HighLevelSimpleClientImpl.EXTRA_INSERTS_SINGLE_BLOCK, HighLevelSimpleClientImpl.EXTRA_INSERTS_SPLITFILE_HEADER, false, cmode, overrideSplitfileKey, false, fcp.core);
                if(logMINOR) Logger.minor(this, "Started global request to insert "+file+" to CHK@ as "+identifier);
                if(clientPut != null)
                  try {
                    fcp.startBlocking(clientPut, context);
                  } catch (IdentifierCollisionException e) {
View Full Code Here

     * @param backup True if we want the .bak file.
     * @param encryptionKey Non-null if we want an encrypted file.
     */
    private Bucket makeBucket(File dir, String baseName, boolean backup, DatabaseKey encryptionKey) {
        File filename = makeFilename(dir, baseName, backup, encryptionKey != null);
        Bucket bucket = new FileBucket(filename, false, false, false, false);
        if(encryptionKey != null)
            bucket = encryptionKey.createEncryptedBucketForClientLayer(bucket);
        return bucket;
    }
View Full Code Here

TOP

Related Classes of freenet.support.io.FileBucket

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.