Package net.sourceforge.fullsync

Examples of net.sourceforge.fullsync.State


   *      net.sourceforge.fullsync.fs.FileAttributes)
   */
  @Override
  public State compareFiles(final File src, final File dst) throws DataParseException {
    if (Math.floor(src.getLastModified() / 1000.0) > Math.floor(dst.getLastModified() / 1000.0)) {
      return new State(State.FileChange, Location.Source);
    }
    else if (Math.floor(src.getLastModified() / 1000.0) < Math.floor(dst.getLastModified() / 1000.0)) {
      return new State(State.FileChange, Location.Destination);
    }
    if (src.getSize() != dst.getSize()) {
      return new State(State.FileChange, Location.None);
    }
    return new State(State.NodeInSync, Location.Both);
  }
View Full Code Here


  private static final Action ignore = new Action(Action.Nothing, Location.None, BufferUpdate.None, "Ignore");

  @Override
  public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException {
    Vector<Action> actions = new Vector<Action>(3);
    State state = sd.getState(src, dst);
    switch (state.getType()) {
      case State.Orphan:
        if (state.getLocation() == Location.Source) {
          if (!bsd.getState(dst).equals(State.Orphan, Location.Source)) {
            actions.add(addDestination);
          }
          else {
            actions.add(overwriteDestination);
          }
        }
        else if (state.getLocation() == Location.Destination) {
          actions.add(deleteDestinationOrphan);
        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Location.Buffer)) {
          actions.add(new Action(Action.Add, Location.Destination, BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Location.Source) {
            actions.add(new Action(Action.Nothing, Location.None, BufferUpdate.Destination,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
View Full Code Here

  }

  @Override
  public State getState(File buffered) throws DataParseException, IOException {
    if (!buffered.isBuffered()) {
      return new State(State.NodeInSync, buffered.exists() ? Location.Both : Location.None);
    }

    File source = buffered.getUnbuffered();
    BufferedFile destination = (BufferedFile) buffered;

    if (!source.exists()) {
      if (!destination.exists()) {
        return new State(State.NodeInSync, Location.None);
      }
      else {
        return new State(State.Orphan, Location.Destination);
      }
    }
    else if (!destination.exists()) {
      return new State(State.Orphan, Location.Source);
    }

    if (source.isDirectory()) {
      if (destination.isDirectory()) {
        return new State(State.NodeInSync, Location.Both);
      }
      else {
        return new State(State.DirHereFileThere, Location.Source);
      }
    }
    else if (destination.isDirectory()) {
      return new State(State.DirHereFileThere, Location.Destination);
    }

    return comparer.compareFiles(source, destination);
  }
View Full Code Here

  private static final Action ignore = new Action(Action.Nothing, Location.None, BufferUpdate.None, "Ignore");

  @Override
  public Task getTask(File src, File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException {
    Vector<Action> actions = new Vector<Action>(3);
    State state = sd.getState(src, dst);
    switch (state.getType()) {
      case State.Orphan:
        if (state.getLocation() == Location.Source) {
          if (!bsd.getState(dst).equals(State.Orphan, Location.Source)) {
            actions.add(addDestination);
          }
          else {
            actions.add(overwriteDestination);
          }
        }
        else if (state.getLocation() == Location.Destination) {
          actions.add(deleteDestination);
        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Location.Buffer)) {
          actions.add(new Action(Action.Add, Location.getOpposite(state.getLocation()), BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Location.Source) {
            actions.add(new Action(Action.Nothing, Location.None, BufferUpdate.None,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
View Full Code Here

  private static final Action ignore = new Action(Nothing, None, BufferUpdate.None, "Ignore");

  @Override
  public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException {
    Vector<Action> actions = new Vector<Action>(3);
    State state = sd.getState(src, dst);
    switch (state.getType()) {
      case State.Orphan:
        if (state.getLocation() == Source) {
          if (!bsd.getState(dst).equals(State.Orphan, Source)) {
            actions.add(addDestination);
          }
          else {
            actions.add(overwriteDestination);
          }
        }
        else if (state.getLocation() == Destination) {
          actions.add(ignoreDestinationOrphan);
          actions.add(deleteDestinationOrphan);
        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Buffer)) {
          actions.add(new Action(Add, Destination, BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Source) {
            actions.add(new Action(Nothing, None, BufferUpdate.Destination,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
View Full Code Here

  private static final Action ignore = new Action(Nothing, None, BufferUpdate.None, "Ignore");

  @Override
  public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException {
    Vector<Action> actions = new Vector<Action>(3);
    State state = sd.getState(src, dst);
    switch (state.getType()) {
      case State.Orphan:
        if (state.getLocation() == Source) {
          if (!bsd.getState(dst).equals(State.Orphan, Source)) {
            actions.add(addDestination);
          }
          else {
            actions.add(ignoreDestinationExists);
            actions.add(overwriteDestination);
          }
        }
        break;
      case State.DirHereFileThere:
        State buff = bsd.getState(dst);
        if (buff.equals(State.Orphan, Buffer)) {
          actions.add(new Action(Add, getOpposite(state.getLocation()), BufferUpdate.Destination,
              "There was a node in buff, but its orphan, so add"));
        }
        else if (buff.equals(State.DirHereFileThere, state.getLocation())) {
          if (state.getLocation() == Source) {
            actions.add(new Action(Nothing, None, BufferUpdate.None,
                "dirherefilethere, but there is a dir instead of file, so its in sync"));
          }
          else {
View Full Code Here

  private static final Action ignore = new Action(Action.Nothing, Location.None, BufferUpdate.None, "Ignore");

  @Override
  public Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException {
    Vector<Action> actions = new Vector<Action>(3);
    State state = sd.getState(src, dst);
    switch (state.getType()) {
      case State.Orphan:
        if (state.getLocation() == Location.Source) {
          actions.add(addToDestination);
          actions.add(deleteSourceOrphan);
        }
        else if (state.getLocation() == Location.Destination) {
          actions.add(addToSource);
          actions.add(deleteDestinationOrphan);
        }
        break;
      case State.DirHereFileThere:
        actions.add(new Action(Action.DirHereFileThereError, state.getLocation(), BufferUpdate.None,
            "file changed from/to dir, can't overwrite"));
        break;
      case State.FileChange:
        if (state.getLocation() == Location.Source) {
          actions.add(updateDestination);
          actions.add(overwriteSource);
        }
        else if (state.getLocation() == Location.Destination) {
          actions.add(updateSource);
          actions.add(overwriteDestination);
        }
        else {
          // TODO a change but we can't tell which file is 'better' (just size changed)
View Full Code Here

    }

    this.actionDecider = actionDecider;

    TaskTree tree = new TaskTree(source, destination);
    Task root = new Task(null, null, new State(State.NodeInSync, Location.None), new Action[] { new Action(Action.Nothing,
        Location.None, BufferUpdate.None, "Root") });
    tree.setRoot(root);

    for (TaskGenerationListener listener : taskGenerationListeners) {
      listener.taskTreeStarted(tree);
View Full Code Here

TOP

Related Classes of net.sourceforge.fullsync.State

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.