Search in sources :

Example 11 with ChangeSet

use of org.syncany.operations.ChangeSet 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

ChangeSet (org.syncany.operations.ChangeSet)11 File (java.io.File)6 Test (org.junit.Test)6 StatusOperation (org.syncany.operations.status.StatusOperation)5 Config (org.syncany.config.Config)4 UpOperation (org.syncany.operations.up.UpOperation)4 StatusOperationResult (org.syncany.operations.status.StatusOperationResult)3 FileVersion (org.syncany.database.FileVersion)2 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)2 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)2 TransferSettings (org.syncany.plugins.transfer.TransferSettings)2 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)2 TestClient (org.syncany.tests.util.TestClient)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Deduper (org.syncany.chunk.Deduper)1 PartialFileHistory (org.syncany.database.PartialFileHistory)1 SqlDatabase (org.syncany.database.SqlDatabase)1 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)1