Search in sources :

Example 1 with LogOperationOptions

use of org.syncany.operations.log.LogOperationOptions in project syncany by syncany.

the class LogCommand method parseOptions.

@Override
public LogOperationOptions parseOptions(String[] operationArgs) throws Exception {
    LogOperationOptions operationOptions = new LogOperationOptions();
    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
    OptionSpec<Integer> optionMaxDatabaseVersionCountStr = parser.acceptsAll(asList("n", "database-count")).withRequiredArg().ofType(Integer.class);
    OptionSpec<Integer> optionStartDatabaseVersionIndexStr = parser.acceptsAll(asList("s", "database-start")).withRequiredArg().ofType(Integer.class);
    OptionSpec<Integer> optionMaxFileHistoryCountStr = parser.acceptsAll(asList("f", "file-count")).withRequiredArg().ofType(Integer.class);
    OptionSpec<Void> optionExcludeEmpty = parser.acceptsAll(asList("x", "exclude-empty"));
    OptionSet options = parser.parse(operationArgs);
    // -x, --exclude-empty
    excludeEmpty = options.has(optionExcludeEmpty);
    // -n, --database-count=..
    if (options.has(optionMaxDatabaseVersionCountStr)) {
        operationOptions.setMaxDatabaseVersionCount(options.valueOf(optionMaxDatabaseVersionCountStr));
    }
    // -s, --database-start=..
    if (options.has(optionStartDatabaseVersionIndexStr)) {
        operationOptions.setStartDatabaseVersionIndex(options.valueOf(optionStartDatabaseVersionIndexStr));
    }
    // -f, --file-count=..
    if (options.has(optionMaxFileHistoryCountStr)) {
        operationOptions.setMaxFileHistoryCount(options.valueOf(optionMaxFileHistoryCountStr));
    }
    return operationOptions;
}
Also used : OptionSet(joptsimple.OptionSet) LogOperationOptions(org.syncany.operations.log.LogOperationOptions) OptionParser(joptsimple.OptionParser)

Example 2 with LogOperationOptions

use of org.syncany.operations.log.LogOperationOptions in project syncany by syncany.

the class LogCommand method execute.

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

Example 3 with LogOperationOptions

use of org.syncany.operations.log.LogOperationOptions in project syncany by syncany.

the class LogOperationTest method testLogOperation.

@Test
public void testLogOperation() throws Exception {
    // Setup
    Config config = TestConfigUtil.createTestLocalConfig();
    StatusOperationOptions statusOptions = new StatusOperationOptions();
    statusOptions.setForceChecksum(true);
    UpOperationOptions upOptions = new UpOperationOptions();
    upOptions.setStatusOptions(statusOptions);
    upOptions.setForceUploadEnabled(true);
    // First, do some uploading
    List<File> originalFiles = TestFileUtil.createRandomFilesInDirectory(config.getLocalDir(), 5 * 1024, 5);
    new UpOperation(config, upOptions).execute();
    // And some more
    for (File file : originalFiles) {
        TestFileUtil.changeRandomPartOfBinaryFile(file);
    }
    new UpOperation(config, upOptions).execute();
    // And some more
    for (File file : originalFiles) {
        file.delete();
    }
    new UpOperation(config, upOptions).execute();
    // Then, check the log
    LogOperationOptions logOptions = new LogOperationOptions();
    logOptions.setStartDatabaseVersionIndex(0);
    logOptions.setMaxDatabaseVersionCount(99);
    logOptions.setMaxFileHistoryCount(99);
    List<LightweightDatabaseVersion> databaseVersions = (new LogOperation(config, logOptions).execute()).getDatabaseVersions();
    assertEquals(3, databaseVersions.size());
    assertEquals(5, databaseVersions.get(2).getChangeSet().getNewFiles().size());
    assertEquals(0, databaseVersions.get(2).getChangeSet().getChangedFiles().size());
    assertEquals(0, databaseVersions.get(2).getChangeSet().getDeletedFiles().size());
    assertEquals(0, databaseVersions.get(1).getChangeSet().getNewFiles().size());
    assertEquals(5, databaseVersions.get(1).getChangeSet().getChangedFiles().size());
    assertEquals(0, databaseVersions.get(1).getChangeSet().getDeletedFiles().size());
    assertEquals(0, databaseVersions.get(0).getChangeSet().getNewFiles().size());
    assertEquals(0, databaseVersions.get(0).getChangeSet().getChangedFiles().size());
    assertEquals(5, databaseVersions.get(0).getChangeSet().getDeletedFiles().size());
    // Cleanup
    TestConfigUtil.deleteTestLocalConfigAndData(config);
}
Also used : UpOperation(org.syncany.operations.up.UpOperation) LogOperation(org.syncany.operations.log.LogOperation) Config(org.syncany.config.Config) LightweightDatabaseVersion(org.syncany.operations.log.LightweightDatabaseVersion) UpOperationOptions(org.syncany.operations.up.UpOperationOptions) StatusOperationOptions(org.syncany.operations.status.StatusOperationOptions) File(java.io.File) LogOperationOptions(org.syncany.operations.log.LogOperationOptions) Test(org.junit.Test)

Aggregations

LogOperationOptions (org.syncany.operations.log.LogOperationOptions)3 LogOperation (org.syncany.operations.log.LogOperation)2 File (java.io.File)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 Test (org.junit.Test)1 Config (org.syncany.config.Config)1 LightweightDatabaseVersion (org.syncany.operations.log.LightweightDatabaseVersion)1 LogOperationResult (org.syncany.operations.log.LogOperationResult)1 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)1 UpOperation (org.syncany.operations.up.UpOperation)1 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)1