Automatic conversion at start-up given correct conditions

This commit is contained in:
Viktor Lofgren 2023-03-04 16:00:17 +01:00
parent 3b5002aac8
commit 6130908285
2 changed files with 9 additions and 5 deletions

View File

@ -86,12 +86,18 @@ public class IndexService extends Service {
} }
private void autoConvert() { private void autoConvert() {
if (!servicesFactory.isConvertedIndexMissing() || !servicesFactory.isPreconvertedIndexPresent()) { if (!servicesFactory.isConvertedIndexMissing()
|| !servicesFactory.isPreconvertedIndexPresent()
|| Boolean.getBoolean("no-auto-convert")
) {
return; return;
} }
try { try {
logger.info("Auto-converting");
searchSetsService.recalculateAll(); searchSetsService.recalculateAll();
searchIndex.switchIndex(); searchIndex.switchIndex();
logger.info("Auto-conversion finished!");
} }
catch (IOException ex) { catch (IOException ex) {
logger.error("Auto convert failed", ex); logger.error("Auto convert failed", ex);

View File

@ -42,9 +42,8 @@ public class IndexServicesFactory {
private final Path searchSetsBase; private final Path searchSetsBase;
int LIVE_PART = 0; final int LIVE_PART = 0;
final int NEXT_PART = 1;
int NEXT_PART = 1;
@Inject @Inject
public IndexServicesFactory( public IndexServicesFactory(
@ -100,7 +99,6 @@ public class IndexServicesFactory {
} }
private void convertFullReverseIndex(DomainRankings domainRankings) throws IOException { private void convertFullReverseIndex(DomainRankings domainRankings) throws IOException {
var source = writerIndexFile.get(0).toPath(); var source = writerIndexFile.get(0).toPath();
logger.info("Converting full reverse index {}", source); logger.info("Converting full reverse index {}", source);