use of org.syncany.operations.ls.LsOperationResult in project syncany by syncany.
the class LsCommand method execute.
@Override
public int execute(String[] operationArgs) throws Exception {
LsOperationOptions operationOptions = parseOptions(operationArgs);
LsOperationResult operationResult = new LsOperation(config, operationOptions).execute();
printResults(operationResult);
return 0;
}
use of org.syncany.operations.ls.LsOperationResult in project syncany by syncany.
the class IdenticalFileMoveScenarioTest method testIdenticalFileMove.
@Test
public void testIdenticalFileMove() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
// Create folder structure
clientA.createNewFolder("folder");
clientA.createNewFolder("folder/subfolder1");
clientA.createNewFolder("folder/subfolder2");
// Create identical files
clientA.createNewFile("folder/subfolder1/A-file1.jpg", 100);
clientA.copyFile("folder/subfolder1/A-file1.jpg", "folder/subfolder2/A-file1.jpg");
clientA.up();
// Move the two identical files
clientA.moveFile("folder", "moved_folder");
clientA.up();
// A just upped, so there should not be changes.
assertFalse(clientA.status().getChangeSet().hasChanges());
// Check if the file histories were based on the correct originals
LsOperationOptions options = new LsOperationOptions();
options.setFetchHistories(true);
options.setPathExpression("moved_folder/subfolder1/");
LsOperationResult lsOperationResult = clientA.ls(options);
for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
}
options.setPathExpression("moved_folder/subfolder2/");
lsOperationResult = clientA.ls(options);
for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
}
// Tear down
clientA.deleteTestData();
}
use of org.syncany.operations.ls.LsOperationResult in project syncany by syncany.
the class LsFolderRequestHandler method handleRequest.
@Override
public Response handleRequest(FolderRequest request) {
LsFolderRequest concreteRequest = (LsFolderRequest) request;
try {
LsOperation operation = new LsOperation(config, concreteRequest.getOptions());
LsOperationResult operationResult = operation.execute();
LsFolderResponse response = new LsFolderResponse(operationResult, request.getId());
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.ls.LsOperationResult in project syncany by syncany.
the class LsCommand method printResults.
@Override
public void printResults(OperationResult operationResult) {
LsOperationResult concreteOperationResult = (LsOperationResult) operationResult;
int longestSize = calculateLongestSize(concreteOperationResult.getFileList());
int longestVersion = calculateLongestVersion(concreteOperationResult.getFileList());
if (fetchHistories) {
printHistories(concreteOperationResult, longestSize, longestVersion);
} else {
printTree(concreteOperationResult, longestSize, longestVersion);
}
}
Aggregations