use of org.syncany.plugins.transfer.StorageMoveException in project syncany by syncany.
the class TransactionAwareFeatureTransferManager method rollbackActions.
/**
* Adds the opposite actions (rollback actions) for the given unfinished actions
* to the rollback transaction.
*/
private void rollbackActions(List<ActionTO> unfinishedActions) throws StorageException {
for (ActionTO action : unfinishedActions) {
logger.log(Level.INFO, "- Needs to be rolled back: " + action);
switch(action.getType()) {
case UPLOAD:
delete(action.getRemoteFile());
delete(action.getTempRemoteFile());
break;
case DELETE:
try {
logger.log(Level.INFO, "- Rollback action: Moving " + action.getTempRemoteFile().getName() + " to " + action.getRemoteFile().getName());
move(action.getTempRemoteFile(), action.getRemoteFile());
} catch (StorageMoveException e) {
logger.log(Level.WARNING, "Restoring deleted file failed. This might be a problem if the original: " + action.getRemoteFile() + " also does not exist.", e);
}
break;
default:
throw new RuntimeException("Transaction contains invalid type: " + action.getType() + ". This should not happen.");
}
}
}
use of org.syncany.plugins.transfer.StorageMoveException in project syncany by syncany.
the class LocalTransferManager method move.
@Override
public void move(RemoteFile sourceFile, RemoteFile targetFile) throws StorageException {
connect();
File sourceRemoteFile = getRemoteFile(sourceFile);
File targetRemoteFile = getRemoteFile(targetFile);
if (!sourceRemoteFile.exists()) {
throw new StorageMoveException("Unable to move file " + sourceFile + " because it does not exist.");
}
try {
FileUtils.moveFile(sourceRemoteFile, targetRemoteFile);
} catch (IOException ex) {
throw new StorageException("Unable to move file " + sourceRemoteFile + " to destination " + targetRemoteFile, ex);
}
}
Aggregations