use of org.syncany.operations.log.LogOperation in project syncany by syncany.
the class LogCommand method execute.
@Override
public int execute(String[] operationArgs) throws Exception {
LogOperationOptions operationOptions = parseOptions(operationArgs);
LogOperationResult operationResult = new LogOperation(config, operationOptions).execute();
printResults(operationResult);
return 0;
}
use of org.syncany.operations.log.LogOperation in project syncany by syncany.
the class LogFolderRequestHandler method handleRequest.
@Override
public Response handleRequest(FolderRequest request) {
LogFolderRequest concreteRequest = (LogFolderRequest) request;
try {
LogOperation operation = new LogOperation(config, concreteRequest.getOptions());
LogOperationResult operationResult = operation.execute();
LogFolderResponse response = new LogFolderResponse(operationResult, request.getId(), request.getRoot());
return response;
} catch (Exception e) {
logger.log(Level.WARNING, "Cannot obtain status.", e);
return new BadRequestResponse(request.getId(), "Cannot execute operation: " + e.getMessage());
}
}
use of org.syncany.operations.log.LogOperation in project syncany by syncany.
the class LogOperationTest method testLogOperation.
@Test
public void testLogOperation() throws Exception {
// Setup
Config config = TestConfigUtil.createTestLocalConfig();
StatusOperationOptions statusOptions = new StatusOperationOptions();
statusOptions.setForceChecksum(true);
UpOperationOptions upOptions = new UpOperationOptions();
upOptions.setStatusOptions(statusOptions);
upOptions.setForceUploadEnabled(true);
// First, do some uploading
List<File> originalFiles = TestFileUtil.createRandomFilesInDirectory(config.getLocalDir(), 5 * 1024, 5);
new UpOperation(config, upOptions).execute();
// And some more
for (File file : originalFiles) {
TestFileUtil.changeRandomPartOfBinaryFile(file);
}
new UpOperation(config, upOptions).execute();
// And some more
for (File file : originalFiles) {
file.delete();
}
new UpOperation(config, upOptions).execute();
// Then, check the log
LogOperationOptions logOptions = new LogOperationOptions();
logOptions.setStartDatabaseVersionIndex(0);
logOptions.setMaxDatabaseVersionCount(99);
logOptions.setMaxFileHistoryCount(99);
List<LightweightDatabaseVersion> databaseVersions = (new LogOperation(config, logOptions).execute()).getDatabaseVersions();
assertEquals(3, databaseVersions.size());
assertEquals(5, databaseVersions.get(2).getChangeSet().getNewFiles().size());
assertEquals(0, databaseVersions.get(2).getChangeSet().getChangedFiles().size());
assertEquals(0, databaseVersions.get(2).getChangeSet().getDeletedFiles().size());
assertEquals(0, databaseVersions.get(1).getChangeSet().getNewFiles().size());
assertEquals(5, databaseVersions.get(1).getChangeSet().getChangedFiles().size());
assertEquals(0, databaseVersions.get(1).getChangeSet().getDeletedFiles().size());
assertEquals(0, databaseVersions.get(0).getChangeSet().getNewFiles().size());
assertEquals(0, databaseVersions.get(0).getChangeSet().getChangedFiles().size());
assertEquals(5, databaseVersions.get(0).getChangeSet().getDeletedFiles().size());
// Cleanup
TestConfigUtil.deleteTestLocalConfigAndData(config);
}
Aggregations