Package org.syncany.operations.cleanup

Examples of org.syncany.operations.cleanup.CleanupOperationResult


    assertEquals("10", TestSqlUtil.runSqlSelect("select count(*) from multichunk", databaseConnectionB));
    assertEquals("11", TestSqlUtil.runSqlSelect("select count(*) from filecontent", databaseConnectionB));
    assertEquals("4", TestSqlUtil.runSqlSelect("select count(distinct id) from filehistory", databaseConnectionB));

    // A: Cleanup this mess (except for two) <<<< This is the interesting part!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(5, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(3, cleanupOperationResult.getRemovedOldVersionsCount());

    // 2 versions for "file.jpg", 2 versions for "otherfile.txt" and one version for "someotherfile.jpg"
    assertEquals("5", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionA));
    assertEquals("7", TestSqlUtil.runSqlSelect("select sum(version) from fileversion where path='file.jpg'", databaseConnectionA)); // 3+4
    assertEquals("5", TestSqlUtil.runSqlSelect("select sum(version) from fileversion where path='otherfile.txt'", databaseConnectionA)); // 2+3
View Full Code Here


    // B: Sync down, add something
    clientB.down();

    clientB.changeFile("file.jpg");

    CleanupOperationResult cleanupOperationResult = clientB.cleanup(cleanupOptions);
    assertEquals(CleanupResultCode.NOK_LOCAL_CHANGES, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

    // A: Add something
    clientA.changeFile("file.jpg");
    clientA.upWithForceChecksum();

    // B: Cleanup
    CleanupOperationResult cleanupOperationResult = clientB.cleanup(options);
    assertEquals(CleanupResultCode.NOK_REMOTE_CHANGES, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

    // B: Sync down, add something
    clientB.down();

    // B: Cleanup
    CleanupOperationResult cleanupOperationResult = clientB.cleanup(options);
    assertEquals(CleanupResultCode.OK_NOTHING_DONE, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

    // B: Sync down
    clientB.down();

    // A: Cleanup
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(2, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(1, cleanupOperationResult.getRemovedOldVersionsCount());

    // A: Continue to upload stuff ! <<<<<<<<<<<<<<<<<<<<<
    for (int i = 1; i <= 4; i++) {
      clientA.changeFile("file.jpg");
      clientA.upWithForceChecksum();
View Full Code Here

    // B: Sync down (creates a local conflict file and marks local changes as DRITY)
    clientB.down(); // << creates DIRTY database entries

    // B: Cleanup
    CleanupOperationResult cleanupOperationResult = clientB.cleanup(removeOldCleanupOperationOptions);
    assertEquals(CleanupResultCode.NOK_DIRTY_LOCAL, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

    // Atomic operation, so multichunk is not yet present at location
    assertEquals(0, repoMultiChunkDir.listFiles().length);
    assertEquals(1, repoActionsDir.listFiles().length);

    // 2. Call A.cleanup(); this does not run, because there are local changes
    CleanupOperationResult cleanupOperationResultA = clientA.cleanup();
    assertEquals(CleanupResultCode.NOK_LOCAL_CHANGES, cleanupOperationResultA.getResultCode());

    // 3. Call B.cleanup(); this does not run, because of the leftover 'action' file
    CleanupOperationResult cleanupOperationResultB = clientB.cleanup();
    assertEquals(CleanupResultCode.NOK_OTHER_OPERATIONS_RUNNING, cleanupOperationResultB.getResultCode());

    // 4. Call B.down(); this does not deliver any results, because no databases have been uploaded
    DownOperationResult downOperationResult = clientB.down();
    assertEquals(DownResultCode.OK_NO_REMOTE_CHANGES, downOperationResult.getResultCode());

    // 5. Call 'up' again, this uploads previously crashed stuff, and then runs cleanup.
    // The cleanup then removes the old multichunk and the old action files.

    UpOperationResult secondUpResult = clientA.up();
    assertEquals(UpResultCode.OK_CHANGES_UPLOADED, secondUpResult.getResultCode());
    assertEquals(2, repoMultiChunkDir.listFiles().length);
    assertEquals(0, repoActionsDir.listFiles().length);

    // 6. Call 'cleanup' manually (Nothing happens, since transaction was cleaned on second up)
    CleanupOperationResult cleanupOperationResult = clientA.cleanup();
    assertEquals(CleanupOperationResult.CleanupResultCode.OK_NOTHING_DONE, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, repoActionsDir.listFiles().length);

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
View Full Code Here

      clientA.changeFile("file.jpg");
      clientA.upWithForceChecksum();
    }

    // B: Cleanup
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(4, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    TestClient clientB = new TestClient("B", testConnection);
    clientB.down();

    // B: Create some file versions
    clientB.createNewFile("file-B.jpg");
    for (int i = 1; i <= 6; i++) {
      clientB.changeFile("file-B.jpg");
      clientB.upWithForceChecksum();
    }

    // B: Cleanup (2 clients, so 7 databases is too much)
    cleanupOperationResult = clientB.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(7, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

      clientA.changeFile("file.jpg");
      clientA.upWithForceChecksum();
    }

    // B: Cleanup
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(16, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    for (int i = 1; i <= 15; i++) {
      clientA.changeFile("file.jpg");
      clientA.upWithForceChecksum();
    }

    // Because of minimum timeout, this cleanup should not do anything
    cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.NOK_RECENTLY_CLEANED, cleanupOperationResult.getResultCode());

    // When force is on, the cleanup should go through
    options.setForce(true);

    cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(16, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());

    // Tear down
    clientA.deleteTestData();
  }
View Full Code Here

        if (upOperationResult.getResultCode() == UpResultCode.OK_CHANGES_UPLOADED && upOperationResult.getChangeSet().hasChanges()) {
          upCount.incrementAndGet();
          notifyChanges = true;
        }   

        CleanupOperationResult cleanupOperationResult = new CleanupOperation(config, options.getCleanupOptions()).execute();
       
        if (cleanupOperationResult.getResultCode() == CleanupResultCode.OK) {
          notifyChanges = true;
        }
       
        // Fire change event if up and/or cleanup 
        if (notifyChanges) {
View Full Code Here

TOP

Related Classes of org.syncany.operations.cleanup.CleanupOperationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.