Package org.syncany.operations

Examples of org.syncany.operations.ChangeSet


    }   
   
    StatusOperationResult statusResult = clientB.status();
    assertNotNull(statusResult);
   
    ChangeSet changes = statusResult.getChangeSet();
   
    assertTrue("Status-Operation should return changes.", changes.hasChanges());
    UpOperationResult upResult = clientB.up();
    StatusOperationResult statusResultFromUp = upResult.getStatusResult();
   
    // Test 1: Check result sets for inconsistencies
    assertTrue("Status should return changes.", statusResultFromUp.getChangeSet().hasChanges());
View Full Code Here


  public void onPostDownOperation(DownEndSyncExternalEvent downEndSyncEvent) {
    if (daemonConfig.getHooks() != null) {
      String runAfterSyncCommand = daemonConfig.getHooks().getRunAfterDownCommand();
     
      if (runAfterSyncCommand != null) {
        ChangeSet changeSet = downEndSyncEvent.getChanges();
       
        List<String> changeMessageParts = new ArrayList<>();
       
        if (changeSet.getNewFiles().size() > 0) {
          changeMessageParts.add(changeSet.getNewFiles().size() + " file(s) added");
        }
       
        if (changeSet.getChangedFiles().size() > 0) {
          changeMessageParts.add(changeSet.getChangedFiles().size() + " file(s) changed");
        }
       
        if (changeSet.getDeletedFiles().size() > 0) {
          changeMessageParts.add(changeSet.getDeletedFiles().size() + " file(s) deleted");
        }
       
        String changedMessage = StringUtil.join(changeMessageParts, ", ");
       
        String escapedSubject = changedMessage.replace("\"", "\\\"");     
View Full Code Here

    startOperation();

    // TODO [medium/high] Remove this and construct mechanism to resume uploads
    transferManager.cleanTransactions();

    ChangeSet localChanges = result.getStatusResult().getChangeSet();
    List<File> locallyUpdatedFiles = extractLocallyUpdatedFiles(localChanges);

    // Index
    DatabaseVersion newDatabaseVersion = index(locallyUpdatedFiles);
View Full Code Here

  private boolean checkPreconditions() throws Exception {
    // Find local changes
    StatusOperation statusOperation = new StatusOperation(config, options.getStatusOptions());
    StatusOperationResult statusOperationResult = statusOperation.execute();
    ChangeSet localChanges = statusOperationResult.getChangeSet();

    result.getStatusResult().setChangeSet(localChanges);

    if (!localChanges.hasChanges()) {
      logger.log(Level.INFO, "Local database is up-to-date (change set). NOTHING TO DO!");
      result.setResultCode(UpResultCode.OK_NO_CHANGES);

      return false;
    }
View Full Code Here

public class StatusOperationResult implements OperationResult {
  private ChangeSet changeSet;

  public StatusOperationResult() {
    changeSet = new ChangeSet();
  }
View Full Code Here

    // Path to actual file version
    final Map<String, FileVersion> filesInDatabase = localDatabase.getCurrentFileTree();

    // Find local changes
    logger.log(Level.INFO, "Analyzing local folder "+config.getLocalDir()+" ...");               
    ChangeSet localChanges = findLocalChanges(filesInDatabase);
   
    if (!localChanges.hasChanges()) {
      logger.log(Level.INFO, "- No changes to local database");
    }
   
    // Return result
    StatusOperationResult statusResult = new StatusOperationResult();
    statusResult.setChangeSet(localChanges);
   
    eventBus.post(new StatusEndSyncExternalEvent(config.getLocalDir().getAbsolutePath(), localChanges.hasChanges()));   
   
    return statusResult;
  }
View Full Code Here

   
    return statusResult;
  }

  private ChangeSet findLocalChanges(final Map<String, FileVersion> filesInDatabase) throws FileNotFoundException, IOException {
    ChangeSet localChanges = findLocalChangedAndNewFiles(config.getLocalDir(), filesInDatabase);
    findAndAppendDeletedFiles(localChanges, filesInDatabase);
   
    return localChanges;
  }   
View Full Code Here

    private ChangeSet changeSet;   
    private Map<String, FileVersion> currentFileTree;
   
    public StatusFileVisitor(Path root, Map<String, FileVersion> currentFileTree) {
      this.root = root;
      this.changeSet = new ChangeSet();
      this.currentFileTree = currentFileTree;
    }
View Full Code Here

   
    // Add new files
    List<File> originalFiles = TestFileUtil.createRandomFilesInDirectory(config.getLocalDir(), 500*1024, 3);
    
    // Status
    ChangeSet changeSet = (new StatusOperation(config).execute()).getChangeSet();       
   
    assertEquals(changeSet.getNewFiles().size(), originalFiles.size());
    assertEquals(changeSet.getChangedFiles().size(), 0);
    assertEquals(changeSet.getDeletedFiles().size(), 0);
       
    // Up
    new UpOperation(config).execute();   
       
    // Status
    changeSet = (new StatusOperation(config).execute()).getChangeSet();   
   
    assertEquals(changeSet.getNewFiles().size(), 0);
    assertEquals(changeSet.getChangedFiles().size(), 0);
    assertEquals(changeSet.getDeletedFiles().size(), 0);

    // Change all files, run 'status'
    Thread.sleep(2000); // TODO [low] StatusOperation relies on file modified time and size, any other methods?

    for (File file : originalFiles) {
      TestFileUtil.changeRandomPartOfBinaryFile(file);
    }   
   
    changeSet = (new StatusOperation(config).execute()).getChangeSet();
   
    assertEquals(changeSet.getNewFiles().size(), 0);
    assertEquals(changeSet.getChangedFiles().size(), originalFiles.size());
    assertEquals(changeSet.getDeletedFiles().size(), 0);
   
    // Up
    new UpOperation(config).execute();
       
    // Delete all files, run 'status' again
    for (File file : originalFiles) {
      TestFileUtil.deleteFile(file);
    }
       
    changeSet = (new StatusOperation(config).execute()).getChangeSet();
   
    assertEquals(changeSet.getNewFiles().size(), 0);
    assertEquals(changeSet.getChangedFiles().size(), 0);
    assertEquals(changeSet.getDeletedFiles().size(), originalFiles.size());
       
    // Cleanup
    TestConfigUtil.deleteTestLocalConfigAndData(config);
  }
View Full Code Here

    // IMPORTANT: Do NOT sleep to enforce checksum-based comparison in 'status'
    new UpOperation(config, syncUpOptions).execute();   
    TestFileUtil.changeRandomPartOfBinaryFile(testFile);
   
    // Run 'status', this should run a checksum-based file comparison
    ChangeSet changeSet = (new StatusOperation(config, statusOptions).execute()).getChangeSet();           
    assertEquals(changeSet.getChangedFiles().size(), 1);
       
    // Cleanup
    TestConfigUtil.deleteTestLocalConfigAndData(config);
  }
View Full Code Here

TOP

Related Classes of org.syncany.operations.ChangeSet

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.