mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-06 12:20:56 +01:00
Fix deletion of repositories from search index (#1813)
This commit is contained in:
2
gradle/changelog/repository_index.yaml
Normal file
2
gradle/changelog/repository_index.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: Fixed
|
||||
description: Deletion of repositories from search index ([#1813](https://github.com/scm-manager/scm-manager/pull/1813))
|
||||
@@ -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> {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user