Search in sources :

Example 11 with DownOperationResult

use of org.syncany.operations.down.DownOperationResult in project syncany by syncany.

the class DownCommand method execute.

@Override
public int execute(String[] operationArgs) throws Exception {
    DownOperationOptions operationOptions = parseOptions(operationArgs);
    DownOperationResult operationResult = new DownOperation(config, operationOptions).execute();
    printResults(operationResult);
    return 0;
}
Also used : DownOperationResult(org.syncany.operations.down.DownOperationResult) DownOperation(org.syncany.operations.down.DownOperation) DownOperationOptions(org.syncany.operations.down.DownOperationOptions)

Example 12 with DownOperationResult

use of org.syncany.operations.down.DownOperationResult in project syncany by syncany.

the class DownCommand method printResults.

@Override
public void printResults(OperationResult operationResult) {
    DownOperationResult concreteOperationResult = (DownOperationResult) operationResult;
    if (concreteOperationResult.getResultCode() == DownResultCode.OK_WITH_REMOTE_CHANGES) {
        ChangeSet changeSet = concreteOperationResult.getChangeSet();
        if (changeSet.hasChanges()) {
            List<String> newFiles = new ArrayList<String>(changeSet.getNewFiles());
            List<String> changedFiles = new ArrayList<String>(changeSet.getChangedFiles());
            List<String> deletedFiles = new ArrayList<String>(changeSet.getDeletedFiles());
            Collections.sort(newFiles);
            Collections.sort(changedFiles);
            Collections.sort(deletedFiles);
            for (String newFile : newFiles) {
                out.println("A " + newFile);
            }
            for (String changedFile : changedFiles) {
                out.println("M " + changedFile);
            }
            for (String deletedFile : deletedFiles) {
                out.println("D " + deletedFile);
            }
        } else {
            out.println(concreteOperationResult.getDownloadedUnknownDatabases().size() + " database file(s) processed.");
        }
        out.println("Sync down finished.");
    } else {
        out.println("Sync down skipped, no remote changes.");
    }
}
Also used : DownOperationResult(org.syncany.operations.down.DownOperationResult) ArrayList(java.util.ArrayList) ChangeSet(org.syncany.operations.ChangeSet)

Aggregations

DownOperationResult (org.syncany.operations.down.DownOperationResult)12 Test (org.junit.Test)9 TestClient (org.syncany.tests.util.TestClient)9 File (java.io.File)6 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)6 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)5 UpOperationResult (org.syncany.operations.up.UpOperationResult)4 TransferSettings (org.syncany.plugins.transfer.TransferSettings)4 FilenameFilter (java.io.FilenameFilter)3 ChangeSet (org.syncany.operations.ChangeSet)2 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)2 DownOperation (org.syncany.operations.down.DownOperation)2 Path (java.nio.file.Path)1 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Config (org.syncany.config.Config)1 DatabaseVersion (org.syncany.database.DatabaseVersion)1 FileVersion (org.syncany.database.FileVersion)1 MemoryDatabase (org.syncany.database.MemoryDatabase)1