mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] do not tolerate io errors from data indexer
This commit is contained in:
@@ -21,12 +21,14 @@ import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.util.io.*;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.impl.FatalErrorConsumer;
|
||||
import com.intellij.vcs.log.impl.VcsChangesLazilyParsedDetails;
|
||||
import com.intellij.vcs.log.util.PersistentUtil;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -52,6 +54,7 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
|
||||
|
||||
public VcsLogPathsIndex(@NotNull String logId,
|
||||
@NotNull Set<VirtualFile> roots,
|
||||
@NotNull FatalErrorConsumer fatalErrorConsumer,
|
||||
@NotNull Disposable disposableParent) throws IOException {
|
||||
super(logId, NAME, VcsLogPersistentIndex.getVersion(), new PathsIndexer(createPathsEnumerator(logId), roots),
|
||||
new NullableIntKeyDescriptor(), disposableParent);
|
||||
@@ -59,6 +62,10 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
|
||||
myEmptyCommits = PersistentUtil.createPersistentHashMap(EnumeratorIntegerDescriptor.INSTANCE, "index-no-" + NAME, logId,
|
||||
VcsLogPersistentIndex.getVersion());
|
||||
myPathsIndexer = (PathsIndexer)myIndexer;
|
||||
myPathsIndexer.setFatalErrorConsumer(e -> {
|
||||
fatalErrorConsumer.consume(this, e);
|
||||
markCorrupted();
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -158,12 +165,17 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
|
||||
private static class PathsIndexer implements DataIndexer<Integer, Integer, VcsFullCommitDetails> {
|
||||
@NotNull private final PersistentEnumeratorBase<String> myPathsEnumerator;
|
||||
@NotNull private final Set<String> myRoots;
|
||||
@NotNull private Consumer<Exception> myFatalErrorConsumer = LOG::error;
|
||||
|
||||
private PathsIndexer(@NotNull PersistentEnumeratorBase<String> enumerator, @NotNull Set<VirtualFile> roots) {
|
||||
myPathsEnumerator = enumerator;
|
||||
myRoots = roots.stream().map(VirtualFile::getPath).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public void setFatalErrorConsumer(@NotNull Consumer<Exception> fatalErrorConsumer) {
|
||||
myFatalErrorConsumer = fatalErrorConsumer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<Integer, Integer> map(@NotNull VcsFullCommitDetails inputData) {
|
||||
@@ -193,7 +205,7 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
|
||||
result.put(myPathsEnumerator.enumerate(changedPath), null);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
myFatalErrorConsumer.consume(e);
|
||||
}
|
||||
});
|
||||
moves.forEach(renamedPaths -> {
|
||||
@@ -205,7 +217,7 @@ public class VcsLogPathsIndex extends VcsLogFullDetailsIndex<Integer> {
|
||||
result.put(afterId, beforeId);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
myFatalErrorConsumer.consume(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -101,8 +101,8 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
|
||||
|
||||
myMessagesIndex = createMap(EnumeratorStringDescriptor.INSTANCE, "messages", logId, 0);
|
||||
myTrigramIndex = createIndex(() -> new VcsLogMessagesTrigramIndex(logId, this));
|
||||
myUserIndex = createIndex(() -> new VcsLogUserIndex(logId, myUserRegistry, this));
|
||||
myPathsIndex = createIndex(() -> new VcsLogPathsIndex(logId, myRoots, this));
|
||||
myUserIndex = createIndex(() -> new VcsLogUserIndex(logId, myUserRegistry, fatalErrorsConsumer, this));
|
||||
myPathsIndex = createIndex(() -> new VcsLogPathsIndex(logId, myRoots, fatalErrorsConsumer, this));
|
||||
|
||||
for (VirtualFile root : myRoots) {
|
||||
myNumberOfTasks.put(root, new AtomicInteger());
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.vcs.log.data.index;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.ScalarIndexExtension;
|
||||
@@ -24,6 +25,7 @@ import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsUser;
|
||||
import com.intellij.vcs.log.data.VcsUserRegistryImpl;
|
||||
import com.intellij.vcs.log.impl.FatalErrorConsumer;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,10 +40,15 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex<Void> {
|
||||
|
||||
public VcsLogUserIndex(@NotNull String logId,
|
||||
@NotNull VcsUserRegistryImpl userRegistry,
|
||||
@NotNull FatalErrorConsumer consumer,
|
||||
@NotNull Disposable disposableParent) throws IOException {
|
||||
super(logId, "users", VcsLogPersistentIndex.getVersion(), new UserIndexer(userRegistry), ScalarIndexExtension.VOID_DATA_EXTERNALIZER,
|
||||
disposableParent);
|
||||
myUserRegistry = userRegistry;
|
||||
((UserIndexer)myIndexer).setFatalErrorConsumer(e -> {
|
||||
consumer.consume(this, e);
|
||||
markCorrupted();
|
||||
});
|
||||
}
|
||||
|
||||
public TIntHashSet getCommitsForUsers(@NotNull Set<VcsUser> users) throws IOException, StorageException {
|
||||
@@ -54,6 +61,7 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex<Void> {
|
||||
|
||||
private static class UserIndexer implements DataIndexer<Integer, Void, VcsFullCommitDetails> {
|
||||
@NotNull private final VcsUserRegistryImpl myRegistry;
|
||||
@NotNull private Consumer<Exception> myFatalErrorConsumer = LOG::error;
|
||||
|
||||
public UserIndexer(@NotNull VcsUserRegistryImpl registry) {
|
||||
myRegistry = registry;
|
||||
@@ -68,10 +76,14 @@ public class VcsLogUserIndex extends VcsLogFullDetailsIndex<Void> {
|
||||
result.put(myRegistry.getUserId(inputData.getAuthor()), null);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
myFatalErrorConsumer.consume(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setFatalErrorConsumer(@NotNull Consumer<Exception> fatalErrorConsumer) {
|
||||
myFatalErrorConsumer = fatalErrorConsumer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user