Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-11173: Fix Unsupported operation exception #11176

Merged
merged 1 commit into from Sep 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,6 +13,7 @@

import static java.nio.file.Files.getLastModifiedTime;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;
import static org.eclipse.che.api.fs.server.WsPathUtils.SEPARATOR;
import static org.eclipse.che.api.fs.server.WsPathUtils.absolutize;
Expand Down Expand Up @@ -266,29 +267,56 @@ private void updateCachedStatus(String project, List<String> paths, Status chang
return;
}

paths.forEach(
path -> {
cachedStatus.getAdded().remove(path);
cachedStatus.getChanged().remove(path);
cachedStatus.getModified().remove(path);
cachedStatus.getUntracked().remove(path);
cachedStatus.getMissing().remove(path);
cachedStatus.getRemoved().remove(path);
cachedStatus.getConflicting().remove(path);
cachedStatus.getUntrackedFolders().remove(path);
});

changes.getAdded().forEach(added -> cachedStatus.getAdded().add(added));
changes.getChanged().forEach(changed -> cachedStatus.getChanged().add(changed));
changes.getModified().forEach(modified -> cachedStatus.getModified().add(modified));
changes.getUntracked().forEach(untracked -> cachedStatus.getUntracked().add(untracked));
changes.getMissing().forEach(missing -> cachedStatus.getMissing().add(missing));
changes.getRemoved().forEach(removed -> cachedStatus.getRemoved().add(removed));
changes.getConflicting().forEach(conflicting -> cachedStatus.getConflicting().add(conflicting));
changes
.getUntrackedFolders()
.forEach(untrackedFolders -> cachedStatus.getUntrackedFolders().add(untrackedFolders));

statusCache.put(project, cachedStatus);
List<String> added =
cachedStatus.getAdded().stream().filter(path -> !paths.contains(path)).collect(toList());
added.addAll(changes.getAdded());

List<String> changed =
cachedStatus.getChanged().stream().filter(path -> !paths.contains(path)).collect(toList());
changed.addAll(changes.getChanged());

List<String> modified =
cachedStatus.getModified().stream().filter(path -> !paths.contains(path)).collect(toList());
modified.addAll(changes.getModified());

List<String> untracked =
cachedStatus.getModified().stream().filter(path -> !paths.contains(path)).collect(toList());
untracked.addAll(changes.getUntracked());

List<String> missing =
cachedStatus.getMissing().stream().filter(path -> !paths.contains(path)).collect(toList());
missing.addAll(changes.getMissing());

List<String> removed =
cachedStatus.getRemoved().stream().filter(path -> !paths.contains(path)).collect(toList());
removed.addAll(changes.getRemoved());

List<String> conflicting =
cachedStatus
.getConflicting()
.stream()
.filter(path -> !paths.contains(path))
.collect(toList());
conflicting.addAll(changes.getConflicting());

List<String> untrackedFolders =
cachedStatus
.getUntrackedFolders()
.stream()
.filter(path -> !paths.contains(path))
.collect(toList());
untrackedFolders.addAll(changes.getUntrackedFolders());

Status status = newDto(Status.class);
status.setAdded(added);
status.setChanged(changed);
status.setModified(modified);
status.setUntracked(untracked);
status.setMissing(missing);
status.setRemoved(removed);
status.setConflicting(conflicting);
status.setUntrackedFolders(untrackedFolders);

statusCache.put(project, status);
}
}