use of org.syncany.plugins.transfer.files.TempRemoteFile in project syncany by syncany.
the class RemoteTransaction method upload.
/**
* Adds a file to this transaction. Generates a temporary file to store it.
*/
public void upload(File localFile, RemoteFile remoteFile) throws StorageException {
TempRemoteFile temporaryRemoteFile = new TempRemoteFile(remoteFile);
logger.log(Level.INFO, "- Adding file to TX for UPLOAD: " + localFile + " -> Temp. remote file: " + temporaryRemoteFile + ", final location: " + remoteFile);
ActionTO action = new ActionTO();
action.setType(ActionType.UPLOAD);
action.setLocalTempLocation(localFile);
action.setRemoteLocation(remoteFile);
action.setRemoteTempLocation(temporaryRemoteFile);
transactionTO.addAction(action);
}
use of org.syncany.plugins.transfer.files.TempRemoteFile in project syncany by syncany.
the class RemoteTransaction method deleteTempRemoteFiles.
/**
* This method deletes the temporary remote files that were the result of deleted files.
*
* Actually deleting remote files is done after finishing the transaction, because
* it cannot be rolled back! If this fails, the temporary files will eventually
* be cleaned up by Cleanup and download will not download these, because
* they are not in any transaction file.
*/
private void deleteTempRemoteFiles() throws StorageException {
boolean success = true;
for (ActionTO action : transactionTO.getActions()) {
if (action.getStatus().equals(ActionStatus.STARTED)) {
// If we are resuming, this action has not been comopleted.
if (action.getType().equals(ActionType.DELETE)) {
RemoteFile tempRemoteFile = action.getTempRemoteFile();
logger.log(Level.INFO, "- Deleting temp. file {0} ...", new Object[] { tempRemoteFile });
try {
transferManager.delete(tempRemoteFile);
} catch (Exception e) {
logger.log(Level.INFO, "Failed to delete: " + tempRemoteFile, " because of: " + e);
success = false;
}
action.setStatus(ActionStatus.DONE);
}
}
}
if (success) {
logger.log(Level.INFO, "END of TX.delTemp(): Sucessfully deleted final files.");
} else {
logger.log(Level.INFO, "END of TX.delTemp(): Did not succesfully delete all files!");
}
}
Aggregations