Ejemplo n.º 1
0
 /**
  * Enqueue a direct GET if not already enqueued, or already downloaded to download dir.
  *
  * @return true if item was enqueued
  */
 public boolean maybeEnqueueDirectGet(
     final FrostDownloadItem dlItem, final long expectedFileSize) {
   if (!isDirectTransferInProgress(dlItem)) {
     final File targetFile = new File(dlItem.getDownloadFilename());
     if (!targetFile.isFile() || targetFile.length() != expectedFileSize) {
       directTransferQueue.appendItemToQueue(dlItem);
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
  public boolean startUpload(final FrostUploadItem ulItem) {
    if (ulItem == null || ulItem.getState() != FrostUploadItem.STATE_WAITING) {
      return false;
    }

    ulItem.setUploadStartedMillis(System.currentTimeMillis());

    ulItem.setState(FrostUploadItem.STATE_PROGRESS);

    // start the upload
    final boolean doMime;
    final boolean setTargetFileName;
    if (ulItem.isSharedFile()) {
      doMime = false;
      setTargetFileName = false;
    } else {
      doMime = true;
      setTargetFileName = true;
    }

    // try to start using DDA
    boolean isDda =
        fcpTools.startPersistentPutUsingDda(
            ulItem.getGqIdentifier(),
            ulItem.getFile(),
            ulItem.getFileName(),
            doMime,
            setTargetFileName,
            ulItem.getCompress(),
            ulItem.getFreenetCompatibilityMode(),
            ulItem.getPriority());

    if (!isDda) {
      // upload was not startet because DDA is not allowed...
      // if UploadManager selected this file then it is not already in progress!
      directTransferQueue.appendItemToQueue(ulItem);
    }
    return true;
  }