use of org.syncany.plugins.transfer.files.ActionRemoteFile in project syncany by syncany.
the class ActionFileHandler method uploadActionFile.
private void uploadActionFile(ActionRemoteFile actionFile) throws Exception {
logger.log(Level.INFO, "Uploading action file: " + actionFile);
File tempActionFile = File.createTempFile("syncany-action-", ".tmp");
tempActionFile.deleteOnExit();
transferManager.upload(tempActionFile, actionFile);
tempActionFile.delete();
}
use of org.syncany.plugins.transfer.files.ActionRemoteFile in project syncany by syncany.
the class AbstractTransferOperation method otherRemoteOperationsRunning.
protected boolean otherRemoteOperationsRunning(String... operationIdentifiers) throws StorageException {
logger.log(Level.INFO, "Looking for other running remote operations ...");
Map<String, ActionRemoteFile> actionRemoteFiles = transferManager.list(ActionRemoteFile.class);
boolean otherRemoteOperationsRunning = false;
List<String> disallowedOperationIdentifiers = Arrays.asList(operationIdentifiers);
for (ActionRemoteFile actionRemoteFile : actionRemoteFiles.values()) {
String operationName = actionRemoteFile.getOperationName();
String machineName = actionRemoteFile.getClientName();
boolean isOwnActionFile = machineName.equals(config.getMachineName());
boolean isOperationAllowed = !disallowedOperationIdentifiers.contains(operationName);
boolean isOutdatedActionFile = isOutdatedActionFile(actionRemoteFile);
if (!isOwnActionFile) {
if (!isOutdatedActionFile) {
if (isOperationAllowed) {
logger.log(Level.INFO, "- Action file from other client, but allowed operation; not marking running; " + actionRemoteFile);
} else {
logger.log(Level.INFO, "- Action file from other client; --> marking operations running (!); " + actionRemoteFile);
otherRemoteOperationsRunning = true;
}
} else {
logger.log(Level.INFO, "- Action file outdated; ignoring " + actionRemoteFile);
}
}
}
return otherRemoteOperationsRunning;
}
use of org.syncany.plugins.transfer.files.ActionRemoteFile in project syncany by syncany.
the class ActionFileHandler method renewActionFile.
private synchronized void renewActionFile() {
try {
logger.log(Level.INFO, "Scheduling action renewal task for every " + (ACTION_RENEWAL_INTERVAL / 60 / 1000) + " minutes, for " + actionFile + " ...");
ActionRemoteFile oldActionFile = actionFile;
ActionRemoteFile newActionFile = new ActionRemoteFile(oldActionFile.getOperationName(), oldActionFile.getClientName(), System.currentTimeMillis());
uploadActionFile(newActionFile);
deleteActionFile(oldActionFile);
actionFile = newActionFile;
} catch (Exception e) {
logger.log(Level.SEVERE, "ERROR: Cannot renew action file!", e);
}
}
use of org.syncany.plugins.transfer.files.ActionRemoteFile in project syncany by syncany.
the class AbstractTransferOperation method cleanActionFiles.
private void cleanActionFiles() throws StorageException {
logger.log(Level.INFO, "Cleaning own old action files ...");
Map<String, ActionRemoteFile> actionRemoteFiles = transferManager.list(ActionRemoteFile.class);
for (ActionRemoteFile actionRemoteFile : actionRemoteFiles.values()) {
String machineName = actionRemoteFile.getClientName();
boolean isOwnActionFile = machineName.equals(config.getMachineName());
boolean isOutdatedActionFile = isOutdatedActionFile(actionRemoteFile);
if (isOwnActionFile) {
logger.log(Level.INFO, "- Deleting own action file " + actionRemoteFile + " ...");
transferManager.delete(actionRemoteFile);
} else if (isOutdatedActionFile) {
logger.log(Level.INFO, "- Action file from other client is OUTDATED; deleting " + actionRemoteFile + " ...");
transferManager.delete(actionRemoteFile);
} else {
logger.log(Level.INFO, "- Action file is current; ignoring " + actionRemoteFile + " ...");
}
}
}
Aggregations