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;
}
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;
}
Aggregations