Package org.syncany.plugins.transfer

Examples of org.syncany.plugins.transfer.TransferManager


    catch (StorageException e) {
      cleanupFailed = true;
    }

    assertTrue(cleanupFailed);
    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
    assertEquals(2, transferManager.list(MultichunkRemoteFile.class).size());
    assertEquals(2, new File(testConnection.getPath(), "multichunks").list().length);
    assertEquals(2, transferManager.list(DatabaseRemoteFile.class).size());
    assertEquals(2, new File(testConnection.getPath(), "databases").list().length);
    assertEquals(1, transferManager.list(TransactionRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "transactions").list().length);
    assertEquals(1, transferManager.list(ActionRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "actions").list().length);

    clientA.cleanup(cleanupOptions);
    assertEquals(1, transferManager.list(MultichunkRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "multichunks").list().length);
    assertEquals(3, transferManager.list(DatabaseRemoteFile.class).size());
    assertEquals(3, new File(testConnection.getPath(), "databases").list().length);
    assertEquals(0, transferManager.list(TransactionRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "transactions").list().length);
    assertEquals(0, transferManager.list(ActionRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "actions").list().length);

    clientA.deleteTestData();
  }
View Full Code Here


    catch (StorageException e) {
      cleanupFailed = true;
    }

    assertTrue(cleanupFailed);
    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
    assertEquals(2, transferManager.list(MultichunkRemoteFile.class).size());
    assertEquals(2, new File(testConnection.getPath(), "multichunks").list().length);

    // Note that the list here differs from the actual files, because the transaction fails
    // while deletions have been done
    assertEquals(2, transferManager.list(DatabaseRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "databases").list().length);

    assertEquals(1, transferManager.list(TransactionRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "transactions").list().length);

    assertEquals(1, transferManager.list(ActionRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "actions").list().length);

    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    File tempFile = File.createTempFile("multichunk", "", tempDir);
    for (RemoteFile remoteFile : transferManager.list(DatabaseRemoteFile.class).values()) {
      transferManager.download(remoteFile, tempFile);
      assertTrue(tempFile.exists());
      tempFile.delete();
    }

    clientA.cleanup(cleanupOptions);

    assertEquals(2, transferManager.list(MultichunkRemoteFile.class).size());
    assertEquals(2, new File(testConnection.getPath(), "multichunks").list().length);

    assertEquals(1, transferManager.list(DatabaseRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "databases").list().length);

    assertEquals(0, transferManager.list(TransactionRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "transactions").list().length);

    assertEquals(0, transferManager.list(ActionRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "actions").list().length);
  }
View Full Code Here

    }
    catch (StorageException e) {
      cleanupFailed = true;
    }

    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);

    assertTrue(cleanupFailed);
    assertEquals(2, transferManager.list(MultichunkRemoteFile.class).size());
    assertEquals(2, new File(testConnection.getPath(), "multichunks").list().length);

    assertEquals(1, transferManager.list(DatabaseRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "databases").list().length);

    assertEquals(0, transferManager.list(TransactionRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "transactions").list().length);

    assertEquals(1, transferManager.list(ActionRemoteFile.class).size());
    assertEquals(1, new File(testConnection.getPath(), "actions").list().length);

    // Two temporary files left (first deletion failed)
    assertEquals(2, transferManager.list(TempRemoteFile.class).size());
    assertEquals(2, new File(testConnection.getPath(), "temporary").list().length);

    clientA.cleanup(cleanupOptions);

    // Functional cleanup results in removal of action file and unreferenced files
    assertEquals(0, transferManager.list(ActionRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "actions").list().length);

    assertEquals(0, transferManager.list(TempRemoteFile.class).size());
    assertEquals(0, new File(testConnection.getPath(), "temporary").list().length);
  }
View Full Code Here

    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));

    // 2. Double check if list() does not return the multichunk
    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
    Map<String, MultichunkRemoteFile> multiChunkList = transferManager.list(MultichunkRemoteFile.class);
    assertEquals(0, multiChunkList.size());

    // 3. Second try fails in the beginning, to see if cleanTransactions was successful
    boolean secondUpFailed = false;
View Full Code Here

    assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
    assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));

    // 2. Double check if list() does not return the multichunk
    TransferManager transferManager = new TransactionAwareTransferManager(
        new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
    Map<String, MultichunkRemoteFile> multiChunkList = transferManager.list(MultichunkRemoteFile.class);
    assertEquals(0, multiChunkList.size());

    // 3. Second try fails in the beginning, to see if cleanTransactions was successful
    boolean secondUpFailed = false;
View Full Code Here

    TransferPlugin plugin = Plugins.get(getPluginId(), TransferPlugin.class);

    TransferSettings connection = plugin.createEmptySettings();

    // This should cause a Storage exception, because the path does not exist
    TransferManager transferManager = plugin.createTransferManager(connection, null);

    transferManager.connect();
  }
View Full Code Here

    // Setup
    File tempFromDir = TestFileUtil.createTempDirectoryInSystemTemp();
    File tempToDir = TestFileUtil.createTempDirectoryInSystemTemp();

    // Create connection, upload, list, download
    TransferManager transferManager = loadPluginAndCreateTransferManager();

    transferManager.init(true);
    transferManager.connect();

    // Clear up previous test (if test location is reused)
    cleanTestLocation(transferManager);

    // Run!
View Full Code Here

    }
  }

  @Test
  public void testDeleteNonExistentFile() throws StorageException {
    TransferManager transferManager = loadPluginAndCreateTransferManager();
    transferManager.connect();

    boolean deleteSuccess = transferManager.delete(new MultichunkRemoteFile("multichunk-dddddddddddddddddddddddddddddddddddddddd")); // does not
                                                                      // exist
    assertTrue(deleteSuccess);
  }
View Full Code Here

    logger.log(Level.INFO, "Running 'Remote Status' at client " + config.getMachineName() + " ...");
    logger.log(Level.INFO, "--------------------------------------------");

    eventBus.post(new LsRemoteStartSyncExternalEvent(config.getLocalDir().getAbsolutePath()));
   
    TransferManager transferManager = (loadedTransferManager != null)
        ? loadedTransferManager
        : config.getTransferPlugin().createTransferManager(config.getConnection(), config);

    List<DatabaseRemoteFile> knownDatabases = localDatabase.getKnownDatabases();
    List<DatabaseRemoteFile> unknownRemoteDatabases = listUnknownRemoteDatabases(transferManager, knownDatabases);

    transferManager.disconnect();

    boolean hasChanges = unknownRemoteDatabases.size() > 0;
    eventBus.post(new LsRemoteEndSyncExternalEvent(config.getLocalDir().getAbsolutePath(), hasChanges));
   
    return new LsRemoteOperationResult(new ArrayList<>(unknownRemoteDatabases));
View Full Code Here

      FileVersion fileVersion = localDatabase.getFileVersion(fileHistoryId, version);
      FileContent fileContent = localDatabase.getFileContent(fileVersion.getChecksum(), true);
      Map<ChunkChecksum, MultiChunkId> multiChunks = localDatabase.getMultiChunkIdsByChecksums(fileContent.getChunks());

      TransferManager transferManager = config.getTransferPlugin().createTransferManager(config.getConnection(), config);
      Downloader downloader = new Downloader(config, transferManager);
      Assembler assembler = new Assembler(config, localDatabase);

      downloader.downloadAndDecryptMultiChunks(new HashSet<MultiChunkId>(multiChunks.values()));
View Full Code Here

TOP

Related Classes of org.syncany.plugins.transfer.TransferManager

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.