Search in sources :

Example 1 with LsOperationResult

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;
}
Also used : LsOperationOptions(org.syncany.operations.ls.LsOperationOptions) LsOperationResult(org.syncany.operations.ls.LsOperationResult) LsOperation(org.syncany.operations.ls.LsOperation)

Example 2 with LsOperationResult

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();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) LsOperationOptions(org.syncany.operations.ls.LsOperationOptions) PartialFileHistory(org.syncany.database.PartialFileHistory) LsOperationResult(org.syncany.operations.ls.LsOperationResult) Test(org.junit.Test)

Example 3 with LsOperationResult

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());
    }
}
Also used : LsOperation(org.syncany.operations.ls.LsOperation) LsOperationResult(org.syncany.operations.ls.LsOperationResult)

Example 4 with LsOperationResult

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);
    }
}
Also used : LsOperationResult(org.syncany.operations.ls.LsOperationResult)

Aggregations

LsOperationResult (org.syncany.operations.ls.LsOperationResult)4 LsOperation (org.syncany.operations.ls.LsOperation)2 LsOperationOptions (org.syncany.operations.ls.LsOperationOptions)2 Test (org.junit.Test)1 PartialFileHistory (org.syncany.database.PartialFileHistory)1 TransferSettings (org.syncany.plugins.transfer.TransferSettings)1 TestClient (org.syncany.tests.util.TestClient)1