Search in sources :

Example 1 with SetAttributesFileSystemAction

use of org.syncany.operations.down.actions.SetAttributesFileSystemAction in project syncany by syncany.

the class FileSystemActionReconciliator method determineActionNoLocalLastVersion.

private void determineActionNoLocalLastVersion(FileVersion winningLastVersion, File winningLastFile, MemoryDatabase winnersDatabase, List<FileSystemAction> outFileSystemActions) throws Exception {
    FileVersionComparison winningFileToVersionComparison = fileVersionComparator.compare(winningLastVersion, winningLastFile, true);
    boolean contentChanged = winningFileToVersionComparison.getFileChanges().contains(FileChange.CHANGED_CHECKSUM) || winningFileToVersionComparison.getFileChanges().contains(FileChange.CHANGED_SIZE);
    if (winningFileToVersionComparison.areEqual()) {
        logger.log(Level.INFO, "     -> (1) Equals: Nothing to do, winning version equals winning file: " + winningLastVersion + " AND " + winningLastFile);
    } else if (winningFileToVersionComparison.getFileChanges().contains(FileChange.DELETED)) {
        FileSystemAction action = new NewFileSystemAction(config, winnersDatabase, assembler, winningLastVersion);
        outFileSystemActions.add(action);
        logger.log(Level.INFO, "     -> (2) Deleted: Local file does NOT exist, but it should, winning version not known: " + winningLastVersion + " AND " + winningLastFile);
        logger.log(Level.INFO, "     -> " + action);
        changeSet.getNewFiles().add(winningLastVersion.getPath());
    } else if (winningFileToVersionComparison.getFileChanges().contains(FileChange.NEW)) {
        FileSystemAction action = new DeleteFileSystemAction(config, null, winningLastVersion, winnersDatabase);
        outFileSystemActions.add(action);
        logger.log(Level.INFO, "     -> (3) New: winning version was deleted, but local exists, winning version = " + winningLastVersion + " at " + winningLastFile);
        logger.log(Level.INFO, "     -> " + action);
        changeSet.getDeletedFiles().add(winningLastVersion.getPath());
    } else if (winningFileToVersionComparison.getFileChanges().contains(FileChange.CHANGED_LINK_TARGET)) {
        FileSystemAction action = new NewSymlinkFileSystemAction(config, winningLastVersion, winnersDatabase);
        outFileSystemActions.add(action);
        logger.log(Level.INFO, "     -> (4) Changed link target: winning file has a different link target: " + winningLastVersion + " AND " + winningLastFile);
        logger.log(Level.INFO, "     -> " + action);
        changeSet.getNewFiles().add(winningLastVersion.getPath());
    } else if (!contentChanged && (winningFileToVersionComparison.getFileChanges().contains(FileChange.CHANGED_LAST_MOD_DATE) || winningFileToVersionComparison.getFileChanges().contains(FileChange.CHANGED_ATTRIBUTES))) {
        FileSystemAction action = new SetAttributesFileSystemAction(config, winningLastVersion, winnersDatabase);
        outFileSystemActions.add(action);
        logger.log(Level.INFO, "     -> (5) Changed file attributes: winning file has different file attributes: " + winningLastVersion + " AND " + winningLastFile);
        logger.log(Level.INFO, "     -> " + action);
        changeSet.getNewFiles().add(winningLastVersion.getPath());
    } else if (winningFileToVersionComparison.getFileChanges().contains(FileChange.CHANGED_PATH)) {
        logger.log(Level.INFO, "     -> (6) Changed path: winning file has a different path: " + winningLastVersion + " AND " + winningLastFile);
        throw new Exception("What happend here?");
    } else {
        // Content changed
        FileSystemAction action = new NewFileSystemAction(config, winnersDatabase, assembler, winningLastVersion);
        outFileSystemActions.add(action);
        logger.log(Level.INFO, "     -> (7) Content changed: Winning file differs from winning version: " + winningLastVersion + " AND " + winningLastFile);
        logger.log(Level.INFO, "     -> " + action);
        changeSet.getNewFiles().add(winningLastVersion.getPath());
    }
}
Also used : NewFileSystemAction(org.syncany.operations.down.actions.NewFileSystemAction) RenameFileSystemAction(org.syncany.operations.down.actions.RenameFileSystemAction) NewFileSystemAction(org.syncany.operations.down.actions.NewFileSystemAction) ChangeFileSystemAction(org.syncany.operations.down.actions.ChangeFileSystemAction) SetAttributesFileSystemAction(org.syncany.operations.down.actions.SetAttributesFileSystemAction) FileSystemAction(org.syncany.operations.down.actions.FileSystemAction) NewSymlinkFileSystemAction(org.syncany.operations.down.actions.NewSymlinkFileSystemAction) DeleteFileSystemAction(org.syncany.operations.down.actions.DeleteFileSystemAction) SetAttributesFileSystemAction(org.syncany.operations.down.actions.SetAttributesFileSystemAction) FileVersionComparison(org.syncany.database.FileVersionComparator.FileVersionComparison) NewSymlinkFileSystemAction(org.syncany.operations.down.actions.NewSymlinkFileSystemAction) DeleteFileSystemAction(org.syncany.operations.down.actions.DeleteFileSystemAction)

Aggregations

FileVersionComparison (org.syncany.database.FileVersionComparator.FileVersionComparison)1 ChangeFileSystemAction (org.syncany.operations.down.actions.ChangeFileSystemAction)1 DeleteFileSystemAction (org.syncany.operations.down.actions.DeleteFileSystemAction)1 FileSystemAction (org.syncany.operations.down.actions.FileSystemAction)1 NewFileSystemAction (org.syncany.operations.down.actions.NewFileSystemAction)1 NewSymlinkFileSystemAction (org.syncany.operations.down.actions.NewSymlinkFileSystemAction)1 RenameFileSystemAction (org.syncany.operations.down.actions.RenameFileSystemAction)1 SetAttributesFileSystemAction (org.syncany.operations.down.actions.SetAttributesFileSystemAction)1