Package org.syncany.operations.down

Examples of org.syncany.operations.down.DownOperationResult


    UpOperationResult upResultB = clientB.up(upOperationOptionsWithForce); // (B1)
    assertEquals(UpResultCode.OK_CHANGES_UPLOADED, upResultB.getResultCode());
    assertEquals(8, upResultB.getChangeSet().getNewFiles().size());

    DownOperationResult downResultA = clientA.down();
    assertEquals(DownResultCode.OK_NO_REMOTE_CHANGES, downResultA.getResultCode());
    assertEquals(0, downResultA.getDirtyDatabasesCreated().size());
    assertEquals(false, downResultA.getChangeSet().hasChanges());

    // For peaking (does NOT affect the test)
    FileUtils.copyFile(new File(testConnection.getPath(), "databases/database-B-0000000001"),
        new File(testConnection.getPath(), "databases/TEMP_db-B-0000000001"));

    DownOperationResult downResultB = clientB.down(); // creates DIRTY; deletes (B1)
    assertEquals(DownResultCode.OK_WITH_REMOTE_CHANGES, downResultB.getResultCode());
    assertEquals(1, downResultB.getDirtyDatabasesCreated().size());
    assertEquals(false, downResultB.getChangeSet().hasChanges()); // TODO [low] Shouldn't this be 'true'?

    // For peaking (does NOT affect the test)
    FileUtils.copyDirectory(clientB.getLocalFile(".syncany/db"), clientB.getLocalFile(".syncany/db_WITH_DIRTY_B1"));

    Files.setPosixFilePermissions(clientB.getLocalFile("sphinxbase-0.8").toPath(), PosixFilePermissions.fromString("rwxrwxrwx"));
View Full Code Here


    // - Create memory database with this version
    MemoryDatabase winnersDatabase = new MemoryDatabase();
    winnersDatabase.addDatabaseVersion(winnersDatabaseVersion);
   
    // Run! Finally!
    DownOperationResult outDownOperationResult = new DownOperationResult();
    FileSystemActionReconciliator fileSystemActionReconciliator = new FileSystemActionReconciliator(testConfigA, outDownOperationResult.getChangeSet());
    List<FileSystemAction> fileSystemActions = fileSystemActionReconciliator.determineFileSystemActions(winnersDatabase);
   
    assertNotNull(fileSystemActions);
    assertEquals(0, fileSystemActions.size());   
   
View Full Code Here

    // 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();
View Full Code Here

       
    // Now move file, and sync
    clientA.moveFile("A-file1", "A-file-moved1");
    clientA.up();
   
    DownOperationResult downOperationResult = clientB.down();   
    assertEquals("No multichunks should have been downloaded.", 0, downOperationResult.getDownloadedMultiChunks().size());
    assertTrue("Moved files should exist.", clientB.getLocalFile("A-file-moved1").exists());   
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
   
    // Tear down
View Full Code Here

      aPosixFilePermissions = Files.getPosixFilePermissions(aFilePath);
      Files.setPosixFilePermissions(bFilePath, PosixFilePermissions.fromString("rwxrwxrwx"));
   
       
    clientA.upWithForceChecksum();   
    DownOperationResult downResult = clientB.down(); // This is the key operation
   
    // Test 1: Check result sets for inconsistencies
    assertTrue("File should be downloaded.", downResult.getChangeSet().hasChanges());
   
    // Test 2: file1.jpg permissions (again!
    if (EnvironmentUtil.isWindows()) {
      Object bReadOnlyAttribute = Files.getAttribute(aFilePath, "dos:readonly");
      assertEquals("Read-only should be true.", aReadOnlyAttribute, bReadOnlyAttribute);
View Full Code Here

     
      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();
View Full Code Here

    assertEquals("Expected to fail, because db-C-1 has not been looked at", UpResultCode.NOK_UNKNOWN_DATABASES, aUpResult.getResultCode());
    assertFalse(clientA.getLocalFile("file2.jpg").exists());
    assertFalse(clientA.getLocalFile("file3.jpg").exists());
   
    // A downloads C's changes, no file changes are expected
    DownOperationResult aDownResult = clientA.down();
    assertEquals("Expected to succeed with remote changes (a new database file, but no file changes!).", DownResultCode.OK_WITH_REMOTE_CHANGES, aDownResult.getResultCode());
    assertTrue(clientA.getLocalFile("file2.jpg").exists());
    assertFalse(clientA.getLocalFile("file3.jpg").exists());
   
    // TODO [low] Add assert: "no file changes are expected"
   
View Full Code Here

  }
 
  @Override
  public int execute(String[] operationArgs) throws Exception {
    DownOperationOptions operationOptions = parseOptions(operationArgs);   
    DownOperationResult operationResult = client.down(operationOptions);   
   
    printResults(operationResult);
   
    return 0;
  }
View Full Code Here

    return operationOptions;
  }

  @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 {
View Full Code Here

    File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());

    hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);

    // 3. This shouldn't do anything; no new databases!
    DownOperationResult downOperationResult = clientIH.down();
    assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());

    // 4. Upload database from client "MOM" (later considered DIRTY)
    clientMOM.createNewFile("fileMOM-1.jpg");
    clientMOM.up(upOptionsWithForce);

    clientMOM.createNewFile("fileMOM-2.jpg");
    clientMOM.up(upOptionsWithForce);

    // 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
    downOperationResult = clientIH.down();
    assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());

    // 6. Rename hidden database (= the later winner!)Now download the changes that
    //    Databases of client "MOM" will be considered "DIRTY"
    hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);

    downOperationResult = clientIH.down();
    assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());

    // 7. This should remove DIRTY database versions from the database
    //    and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
    clientIH.up();
View Full Code Here

TOP

Related Classes of org.syncany.operations.down.DownOperationResult

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.