Package org.syncany.database

Examples of org.syncany.database.FileVersion


    newDatabaseVersionHeader.setVectorClock(TestDatabaseUtil.createVectorClock("A5,C1"));
   
    newDatabaseVersion.setHeader(newDatabaseVersionHeader);
   
    PartialFileHistory newFileHistory = new PartialFileHistory(FileHistoryId.secureRandomFileId());
    FileVersion newFileVersion = new FileVersion();
   
    newFileVersion.setVersion(1L);
    newFileVersion.setPath("newfile");
    newFileVersion.setChecksum(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"));
    newFileVersion.setLinkTarget(null);
    newFileVersion.setPosixPermissions("rwxrwxrwx");
    newFileVersion.setDosAttributes(null);
    newFileVersion.setStatus(FileStatus.NEW);
    newFileVersion.setLastModified(new Date());
    newFileVersion.setUpdated(new Date());
    newFileVersion.setSize(1L);
    newFileVersion.setType(FileType.FILE);

    newFileHistory.addFileVersion(newFileVersion);
    newDatabaseVersion.addFileHistory(newFileHistory);

    ChunkEntry newChunkEntry = new ChunkEntry(ChunkChecksum.parseChunkChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"), 1);
View Full Code Here


  public void testCaptureFilePropertiesFromFileVersion() throws Exception {
    // Setup
    Config config = TestConfigUtil.createTestLocalConfig();
    FileVersionComparator versionComparator = new FileVersionComparator(config.getLocalDir(), config.getChunker().getChecksumAlgorithm());
   
    FileVersion fileVersion = new FileVersion();
    fileVersion.setVersion(3L);

    fileVersion.setChecksum(new FileChecksum(new byte[] { 0x11, 0x22, 0x33 }));
    fileVersion.setLastModified(new Date(123456789));
    fileVersion.setPath("folder/file");
    fileVersion.setSize(999*1024L);
    fileVersion.setLinkTarget(null);
    fileVersion.setStatus(FileStatus.CHANGED);
    fileVersion.setType(FileType.FILE);
   
    if (EnvironmentUtil.isWindows()) {
      fileVersion.setDosAttributes("rha-");
    }
    else if (EnvironmentUtil.isUnixLikeOperatingSystem()) {
      fileVersion.setPosixPermissions("rw-rw-r-x");
    }
   
    // Run
    FileProperties fileProperties = versionComparator.captureFileProperties(fileVersion);
   
View Full Code Here

    else if (EnvironmentUtil.isUnixLikeOperatingSystem()) {
      Files.setPosixFilePermissions(somefilePath, PosixFilePermissions.fromString("r--rwxrw-"));
    }
   
    // Create FileVersion
    FileVersion fileVersion = new FileVersion();
    fileVersion.setVersion(100L);

    fileVersion.setChecksum(new FileChecksum(new byte[] { 0x11, 0x22, 0x33 })); // << definitely differs
    fileVersion.setLastModified(new Date(1182196000));
    fileVersion.setPath("file1");
    fileVersion.setSize(130*1024L);
    fileVersion.setLinkTarget(null);
    fileVersion.setStatus(FileStatus.NEW);
    fileVersion.setType(FileType.FILE);
   
    if (EnvironmentUtil.isWindows()) {
      fileVersion.setDosAttributes("r-a-");
    }
    else if (EnvironmentUtil.isUnixLikeOperatingSystem()) {
      fileVersion.setPosixPermissions("r--rwxrw-");
    }
   
    // Run
    FileVersionComparison fileComparison = versionComparator.compare(fileVersion, somefile, null, true);
   
View Full Code Here

  protected Map<FileHistoryId, PartialFileHistory> createFileHistoriesFromResult(ResultSet resultSet) throws SQLException {
    Map<FileHistoryId, PartialFileHistory> fileHistories = new HashMap<FileHistoryId, PartialFileHistory>();;
    PartialFileHistory fileHistory = null;

    while (resultSet.next()) {
      FileVersion lastFileVersion = fileVersionDao.createFileVersionFromRow(resultSet);
      FileHistoryId fileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
     
      // Old history (= same filehistory identifier)
      if (fileHistory != null && fileHistory.getFileHistoryId().equals(fileHistoryId)) { // Same history!
        fileHistory.addFileVersion(lastFileVersion);
View Full Code Here

    try (PreparedStatement preparedStatement = getStatement("filehistory.select.master.getFileHistoriesWithLastVersion.sql")) {
      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
          FileHistoryId fileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
          FileVersion lastFileVersion = fileVersionDao.createFileVersionFromRow(resultSet);
 
          PartialFileHistory fileHistory = new PartialFileHistory(fileHistoryId);
          fileHistory.addFileVersion(lastFileVersion);
 
          fileHistories.add(fileHistory);
View Full Code Here

      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        while (resultSet.next()) {
          FileHistoryId purgeFileHistoryId = FileHistoryId.parseFileId(resultSet.getString("filehistory_id"));
         
          // Create max purge version with dummy values (mandatory for XML serialization)
          FileVersion maxPurgeFileVersion = new FileVersion();
         
          maxPurgeFileVersion.setFileHistoryId(purgeFileHistoryId);
          maxPurgeFileVersion.setVersion(resultSet.getLong("fileversion_maxpurgeversion"));
         
          maxPurgeFileVersion.setPath("");
          maxPurgeFileVersion.setType(FileType.FILE);
          maxPurgeFileVersion.setStatus(FileStatus.DELETED);
          maxPurgeFileVersion.setSize(0L);
          maxPurgeFileVersion.setLastModified(new Date());
 
          PartialFileHistory fileHistory = new PartialFileHistory(purgeFileHistoryId);
          fileHistory.addFileVersion(maxPurgeFileVersion);
 
          fileHistories.add(fileHistory);
View Full Code Here

   
    // - Create new version (delete folder)
    TestSqlDatabase sqlDatabaseA = new TestSqlDatabase(testConfigA);
    PartialFileHistory folderFileHistoryWithLastVersion = sqlDatabaseA.getFileHistoryWithLastVersion("new folder/some subfolder");

    FileVersion deletedFolderVersion = folderFileHistoryWithLastVersion.getLastVersion().clone();
    deletedFolderVersion.setStatus(FileStatus.DELETED);
    deletedFolderVersion.setVersion(deletedFolderVersion.getVersion()+1);
   
    PartialFileHistory deletedFolderVersionHistory = new PartialFileHistory(folderFileHistoryWithLastVersion.getFileHistoryId());
    deletedFolderVersionHistory.addFileVersion(deletedFolderVersion);
   
    DatabaseVersion winnersDatabaseVersion = TestDatabaseUtil.createDatabaseVersion(sqlDatabaseA.getLastDatabaseVersionHeader());   
View Full Code Here

  }
 
  @Test(expected = IllegalArgumentException.class)
  public void testFileHistoryAddFileVersionInvalidVersionNull() {
    PartialFileHistory fileHistory = new PartialFileHistory(FileHistoryId.parseFileId("1234"));
    fileHistory.addFileVersion(new FileVersion());
  }
View Full Code Here

    fileHistory.addFileVersion(new FileVersion());
  }
 
  @Test
  public void testFileHistoryGetVersionsNonEmpty() {
    FileVersion fileVersion = new FileVersion();
    fileVersion.setVersion(5L);
    fileVersion.setPath("/somepath");
   
    PartialFileHistory fileHistory = new PartialFileHistory(FileHistoryId.parseFileId("1234"));
    fileHistory.addFileVersion(fileVersion);
   
    assertNotNull(fileHistory.getLastVersion());
View Full Code Here

    assertEquals(fileVersion, fileHistory.getFileVersion(5L));
 
 
  @Test
  public void testFileHistoryClone() {
    FileVersion fileVersion1 = new FileVersion();
    fileVersion1.setVersion(1L);
    fileVersion1.setPath("/somepath");
   
    FileVersion fileVersion2 = new FileVersion();
    fileVersion2.setVersion(2L);
    fileVersion2.setPath("/somepath");

    PartialFileHistory fileHistory = new PartialFileHistory(FileHistoryId.parseFileId("1234"));
    fileHistory.addFileVersion(fileVersion1);
    fileHistory.addFileVersion(fileVersion2);
   
    PartialFileHistory fileHistoryClone = fileHistory.clone();
   
    assertEquals(fileHistory, fileHistoryClone);
    assertEquals(fileHistory.getFileVersions().size(), fileHistoryClone.getFileVersions().size());
    assertEquals(fileHistory.getFileVersions(), fileHistoryClone.getFileVersions());

    FileVersion fileVersion3 = new FileVersion();
    fileVersion3.setVersion(3L);
    fileVersion3.setPath("/somepath");
   
    fileHistoryClone.addFileVersion(fileVersion3);
    assertEquals(fileHistory.getFileVersions().size()+1, fileHistoryClone.getFileVersions().size());
 
View Full Code Here

TOP

Related Classes of org.syncany.database.FileVersion

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.