Search in sources :

Example 6 with TransactionRemoteFile

use of org.syncany.plugins.transfer.files.TransactionRemoteFile in project syncany by syncany.

the class TransactionAwareFeatureTransferManager method retrieveRemoteTransactions.

private Map<TransactionTO, TransactionRemoteFile> retrieveRemoteTransactions() throws StorageException {
    Map<String, TransactionRemoteFile> transactionFiles = list(TransactionRemoteFile.class);
    Map<TransactionTO, TransactionRemoteFile> transactions = new HashMap<TransactionTO, TransactionRemoteFile>();
    for (TransactionRemoteFile transaction : transactionFiles.values()) {
        try {
            File transactionFile = createTempFile("transaction");
            try {
                // Download transaction file
                download(transaction, transactionFile);
            } catch (StorageFileNotFoundException e) {
                // This happens if the file is deleted between listing and downloading. It is now final, so we skip it.
                logger.log(Level.INFO, "Could not find transaction file: " + transaction);
                continue;
            }
            Transformer transformer = config == null ? null : config.getTransformer();
            TransactionTO transactionTO = TransactionTO.load(transformer, transactionFile);
            // Extract final locations
            transactions.put(transactionTO, transaction);
            transactionFile.delete();
        } catch (Exception e) {
            throw new StorageException("Failed to read transactionFile", e);
        }
    }
    return transactions;
}
Also used : StorageFileNotFoundException(org.syncany.plugins.transfer.StorageFileNotFoundException) TransactionRemoteFile(org.syncany.plugins.transfer.files.TransactionRemoteFile) Transformer(org.syncany.chunk.Transformer) HashMap(java.util.HashMap) RemoteFile(org.syncany.plugins.transfer.files.RemoteFile) TempRemoteFile(org.syncany.plugins.transfer.files.TempRemoteFile) TransactionRemoteFile(org.syncany.plugins.transfer.files.TransactionRemoteFile) File(java.io.File) StorageException(org.syncany.plugins.transfer.StorageException) StorageException(org.syncany.plugins.transfer.StorageException) BlockingTransfersException(org.syncany.operations.up.BlockingTransfersException) IOException(java.io.IOException) StorageMoveException(org.syncany.plugins.transfer.StorageMoveException) StorageFileNotFoundException(org.syncany.plugins.transfer.StorageFileNotFoundException) TransactionTO(org.syncany.plugins.transfer.to.TransactionTO)

Example 7 with TransactionRemoteFile

use of org.syncany.plugins.transfer.files.TransactionRemoteFile in project syncany by syncany.

the class RemoteTransaction method uploadTransactionFile.

/**
	 * This method uploads a local copy of the transaction to the repository. This is done at the begin of commit()
	 * and is the starting point of the transaction itself.
	 */
private TransactionRemoteFile uploadTransactionFile(File localTransactionFile) throws StorageException {
    TransactionRemoteFile remoteTransactionFile = new TransactionRemoteFile(this);
    eventBus.post(new UpUploadFileSyncExternalEvent(config.getLocalDir().getAbsolutePath(), remoteTransactionFile.getName()));
    logger.log(Level.INFO, "- Uploading remote transaction file {0} ...", remoteTransactionFile);
    transferManager.upload(localTransactionFile, remoteTransactionFile);
    return remoteTransactionFile;
}
Also used : TransactionRemoteFile(org.syncany.plugins.transfer.files.TransactionRemoteFile) UpUploadFileSyncExternalEvent(org.syncany.operations.daemon.messages.UpUploadFileSyncExternalEvent)

Aggregations

TransactionRemoteFile (org.syncany.plugins.transfer.files.TransactionRemoteFile)7 TransactionTO (org.syncany.plugins.transfer.to.TransactionTO)4 TempRemoteFile (org.syncany.plugins.transfer.files.TempRemoteFile)3 ActionTO (org.syncany.plugins.transfer.to.ActionTO)3 File (java.io.File)2 BlockingTransfersException (org.syncany.operations.up.BlockingTransfersException)2 RemoteFile (org.syncany.plugins.transfer.files.RemoteFile)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Transformer (org.syncany.chunk.Transformer)1 UpUploadFileSyncExternalEvent (org.syncany.operations.daemon.messages.UpUploadFileSyncExternalEvent)1 StorageException (org.syncany.plugins.transfer.StorageException)1 StorageFileNotFoundException (org.syncany.plugins.transfer.StorageFileNotFoundException)1 StorageMoveException (org.syncany.plugins.transfer.StorageMoveException)1