Fix deletion of repositories from search index (#1813)

This commit is contained in:
Sebastian Sdorra
2021-09-27 13:15:29 +02:00
committed by GitHub
parent ad2dfa42fd
commit 24effd9041
3 changed files with 12 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
- type: Fixed
description: Deletion of repositories from search index ([#1813](https://github.com/scm-manager/scm-manager/pull/1813))

View File

@@ -43,7 +43,7 @@ import javax.inject.Singleton;
public class RepositoryIndexer implements Indexer<Repository> {
@VisibleForTesting
static final int VERSION = 3;
static final int VERSION = 4;
private final SearchEngine searchEngine;
@@ -92,7 +92,7 @@ public class RepositoryIndexer implements Indexer<Repository> {
public SerializableIndexTask<Repository> createDeleteTask(Repository repository) {
return index -> {
if (Repository.class.equals(index.getDetails().getType())) {
index.delete().byId(Id.of(Repository.class, repository.getId()));
index.delete().byId(id(repository));
} else {
index.delete().by(Repository.class, repository).execute();
}
@@ -101,9 +101,14 @@ public class RepositoryIndexer implements Indexer<Repository> {
private static void store(Index<Repository> index, Repository repository) {
index.store(
Id.of(Repository.class, repository).and(repository),
id(repository),
RepositoryPermissions.read(repository).asShiroString(),
repository);
repository
);
}
private static Id<Repository> id(Repository repository) {
return Id.of(Repository.class, repository).and(repository);
}
public static class ReIndexAll extends ReIndexAllTask<Repository> {

View File

@@ -97,7 +97,7 @@ class RepositoryIndexerTest {
when(index.getDetails().getType()).then(ic -> Repository.class);
indexer.createDeleteTask(heartOfGold).update(index);
verify(index.delete()).byId(Id.of(Repository.class, heartOfGold));
verify(index.delete()).byId(Id.of(Repository.class, heartOfGold).and(heartOfGold));
}
@Test