Search in sources :

Example 1 with CleanupOperation

use of org.syncany.operations.cleanup.CleanupOperation in project syncany by syncany.

the class CleanupCommand method execute.

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

Example 2 with CleanupOperation

use of org.syncany.operations.cleanup.CleanupOperation in project syncany by syncany.

the class WatchOperation method runSync.

/**
	 * Runs one iteration of the main synchronization loop, containing a {@link DownOperation},
	 * an {@link UpOperation} and (if required), a {@link CleanupOperation}.
	 */
private void runSync() throws Exception {
    if (!syncRunning.get()) {
        syncRunning.set(true);
        syncRequested.set(false);
        logger.log(Level.INFO, "RUNNING SYNC ...");
        fireStartEvent();
        try {
            boolean notifyChanges = false;
            // Run down
            DownOperationResult downResult = new DownOperation(config, options.getDownOptions()).execute();
            if (downResult.getResultCode() == DownResultCode.OK_WITH_REMOTE_CHANGES) {
            // TODO [low] Do something?
            }
            // Run up
            UpOperationResult upOperationResult = new UpOperation(config, options.getUpOptions()).execute();
            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) {
                notifyChanges();
            }
        } finally {
            logger.log(Level.INFO, "SYNC DONE.");
            syncRunning.set(false);
            fireEndEvent();
        }
    } else {
        // Can't do a log message here, because this bit is called thousand
        // of times when file system events occur.
        syncRequested.set(true);
    }
}
Also used : UpOperation(org.syncany.operations.up.UpOperation) CleanupOperationResult(org.syncany.operations.cleanup.CleanupOperationResult) DownOperationResult(org.syncany.operations.down.DownOperationResult) DownOperation(org.syncany.operations.down.DownOperation) CleanupOperation(org.syncany.operations.cleanup.CleanupOperation) UpOperationResult(org.syncany.operations.up.UpOperationResult)

Aggregations

CleanupOperation (org.syncany.operations.cleanup.CleanupOperation)2 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)2 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)1 DownOperation (org.syncany.operations.down.DownOperation)1 DownOperationResult (org.syncany.operations.down.DownOperationResult)1 UpOperation (org.syncany.operations.up.UpOperation)1 UpOperationResult (org.syncany.operations.up.UpOperationResult)1