mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Check VFS event for validity during async processing EA-109103
This commit is contained in:
@@ -17,6 +17,7 @@ package git4idea.repo;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
@@ -295,13 +296,18 @@ public class GitUntrackedFilesHolder implements Disposable, AsyncVfsEventsListen
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getAffectedFile(@NotNull VFileEvent event) {
|
||||
if (event instanceof VFileCreateEvent || event instanceof VFileDeleteEvent || event instanceof VFileMoveEvent || isRename(event)) {
|
||||
return event.getFile();
|
||||
} else if (event instanceof VFileCopyEvent) {
|
||||
VFileCopyEvent copyEvent = (VFileCopyEvent) event;
|
||||
return copyEvent.getNewParent().findChild(copyEvent.getNewChildName());
|
||||
}
|
||||
return null;
|
||||
return ReadAction.compute(() -> {
|
||||
if (!event.isValid()) return null;
|
||||
|
||||
if (event instanceof VFileCreateEvent || event instanceof VFileDeleteEvent || event instanceof VFileMoveEvent || isRename(event)) {
|
||||
return event.getFile();
|
||||
}
|
||||
else if (event instanceof VFileCopyEvent) {
|
||||
VFileCopyEvent copyEvent = (VFileCopyEvent) event;
|
||||
return copyEvent.getNewParent().findChild(copyEvent.getNewChildName());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isRename(@NotNull VFileEvent event) {
|
||||
|
||||
Reference in New Issue
Block a user