@Override public String toString() { if(diffStatus == NONE) { return getRelativePath(); } return new StringBuilder().append(getRelativePath()).append('(').append(diffStatus).append(')').toString(); } }
private void persistDirHashes(Path hashes, FsEntry entry, List<FsEntry> dirs) throws ProvisioningException { final Path target = hashes.resolve(entry.getRelativePath()); try { Files.createDirectory(target); } catch (IOException e) { throw new ProvisioningException(Errors.hashesNotPersisted(), e); } if (entry.hasChildren()) { persistChildHashes(hashes, entry, dirs, target); } }
private static void addEntries(FsEntry entry, List<Change> changes, char tag) { if (entry.hasChildren()) { for (FsEntry child : entry.getChildren()) { addEntries(child, changes, tag); } } else { changes.add(new Change(entry.getRelativePath(), tag)); } }
private void doDiff(FsEntry originalEntry, FsEntry otherEntry) throws ProvisioningException { if(originalEntry.isDir() != otherEntry.isDir()) { removed = CollectionUtils.put(removed, originalEntry.getRelativePath(), originalEntry); added = CollectionUtils.put(added, otherEntry.getRelativePath(), otherEntry); return; if(otherChild == null) { originalChild.diffRemoved(); removed = CollectionUtils.put(removed, originalChild.getRelativePath(), originalChild); continue; for (FsEntry otherChild : otherChildren.values()) { otherChild.diffAdded(); added = CollectionUtils.put(added, otherChild.getRelativePath(), otherChild); for (FsEntry otherChild : otherEntry.getChildren()) { otherChild.diffAdded(); added = CollectionUtils.put(added, otherChild.getRelativePath(), otherChild); originalEntry.diffModified(); otherEntry.diffModified(); modified = CollectionUtils.put(modified, originalEntry.getRelativePath(), new FsEntry[] {originalEntry, otherEntry});
continue; final Path target = home.resolve(removed.getRelativePath()); if(Files.exists(target)) { log.print(formatMessage(REMOVED, removed.getRelativePath(), null)); IoUtils.recursiveDelete(target); } else { log.verbose(formatMessage(REMOVED, removed.getRelativePath(), HAS_BEEN_REMOVED_FROM_THE_UPDATED_VERSION)); undoTasks = CollectionUtils.putLinked(undoTasks, removed.getRelativePath(), false); final Path target = home.resolve(update.getRelativePath()); char action = MODIFIED; String warning = null; action = REPLAY_SKIP; undoTasks = CollectionUtils.putLinked(undoTasks, update.getRelativePath(), true); } else if (!Arrays.equals(modified[0].getHash(), targetHash)) { if (modifiedPathUpdated(update)) { log.print(formatMessage(action, update.getRelativePath(), warning)); try { IoUtils.copy(update.getPath(), target);
private static Map<String, Boolean> addFsEntry(Path home, FsEntry added, Map<String, Boolean> undoTasks, MessageWriter log) throws ProvisioningException { final Path target = home.resolve(added.getRelativePath()); char action = ADDED; String warning = null; action = MODIFIED; undoTasks = CollectionUtils.putLinked(undoTasks, added.getRelativePath(), true); } else if(addedPathConflict(added) && !added.isDir()) { warning = CONFLICTS_WITH_THE_UPDATED_VERSION; log.print(formatMessage(action, added.getRelativePath(), warning)); try { IoUtils.copy(added.getPath(), target);