use of org.syncany.operations.daemon.messages.api.FolderRequestHandler in project syncany by syncany.
the class WatchRunner method onRequestReceived.
@Subscribe
public void onRequestReceived(FolderRequest folderRequest) {
File requestRootFolder = new File(folderRequest.getRoot());
boolean localDirMatches = requestRootFolder.equals(config.getLocalDir());
if (localDirMatches) {
logger.log(Level.INFO, "Received " + folderRequest);
try {
if (!watchOperation.isSyncRunning() && !watchOperation.isSyncRequested()) {
watchOperation.pause();
FolderRequestHandler handler = FolderRequestHandler.createFolderRequestHandler(folderRequest, config);
Response response = handler.handleRequest(folderRequest);
if (response != null) {
eventBus.post(response);
}
watchOperation.resume();
} else {
logger.log(Level.WARNING, "FolderRequest discarded : ", folderRequest);
eventBus.post(new AlreadySyncingResponse(folderRequest.getId(), "FolderRequest discarded."));
}
} catch (Exception e) {
logger.log(Level.FINE, "Failed to process request", e);
eventBus.post(new BadRequestResponse(folderRequest.getId(), "Invalid request."));
}
}
}
Aggregations