Remove excessive injection stack from InitIndex

All this class needs to do is mark an empty index as ready. Factor out
a small static method to do this work.

Change-Id: Id0bcef9cb7e5a6879288ed4716ea45fb6539f07c
This commit is contained in:
Dave Borowitz
2014-02-05 16:58:14 -08:00
parent 5ac379ca64
commit fc9d9628cd
2 changed files with 15 additions and 130 deletions

View File

@@ -134,6 +134,18 @@ public class LuceneChangeIndex implements ChangeIndex {
LUCENE_VERSIONS = versions.build();
}
public static void setReady(SitePaths sitePaths, int version, boolean ready)
throws IOException {
try {
FileBasedConfig cfg =
LuceneVersionManager.loadGerritIndexConfig(sitePaths);
LuceneVersionManager.setReady(cfg, version, ready);
cfg.save();
} catch (ConfigInvalidException e) {
throw new IOException(e);
}
}
static interface Factory {
LuceneChangeIndex create(Schema<ChangeData> schema, String base);
}
@@ -304,13 +316,7 @@ public class LuceneChangeIndex implements ChangeIndex {
@Override
public void markReady(boolean ready) throws IOException {
try {
FileBasedConfig cfg = LuceneVersionManager.loadGerritIndexConfig(sitePaths);
LuceneVersionManager.setReady(cfg, schema.getVersion(), ready);
cfg.save();
} catch (ConfigInvalidException e) {
throw new IOException(e);
}
setReady(sitePaths, schema.getVersion(), ready);
}
private static final ImmutableSet<String> FIELDS =