diff --git a/src/main/java/com/andrewlalis/d_package_search/DPackageSearch.java b/src/main/java/com/andrewlalis/d_package_search/DPackageSearch.java index a116d97..3a84e2d 100644 --- a/src/main/java/com/andrewlalis/d_package_search/DPackageSearch.java +++ b/src/main/java/com/andrewlalis/d_package_search/DPackageSearch.java @@ -26,9 +26,17 @@ public class DPackageSearch { private static void startIndexerThread(IndexGenerator indexGenerator) { Thread.ofVirtual().start(() -> { while (true) { + System.out.println("Will re-index packages in 10 seconds"); + try { + Thread.sleep(Duration.ofSeconds(10)); + } catch (InterruptedException e) { + System.err.println("Indexing thread interrupted: " + e.getMessage()); + break; + } + System.out.println("Re-indexing packages now."); indexGenerator.run(); try { - Thread.sleep(Duration.ofMinutes(5)); + Thread.sleep(Duration.ofMinutes(60)); } catch (InterruptedException e) { System.err.println("Indexing thread interrupted: " + e.getMessage()); break; diff --git a/src/main/java/com/andrewlalis/d_package_search/IndexGenerator.java b/src/main/java/com/andrewlalis/d_package_search/IndexGenerator.java index 4ec5ecf..fa14ec9 100644 --- a/src/main/java/com/andrewlalis/d_package_search/IndexGenerator.java +++ b/src/main/java/com/andrewlalis/d_package_search/IndexGenerator.java @@ -25,13 +25,14 @@ public record IndexGenerator( Collection packages; try { packages = fetcher.fetch(); + dur = Duration.between(start, Instant.now()); + System.out.println("Fetched " + packages.size() + " in " + dur.toMillis() + " ms."); } catch (IOException e) { System.err.println("Failed to fetch packages: " + e.getMessage()); return; } + try (PackageIndexer indexer = indexerSupplier.get()) { - dur = Duration.between(start, Instant.now()); - System.out.println("Fetched " + packages.size() + " in " + dur.toMillis() + " ms."); start = Instant.now(); for (var pkg : packages) { indexer.addToIndex(pkg);