@@ -161,15 +161,17 @@ private List<Head> loadFullSnapshot() {
161161 for (String sourceUrl : sourceUrls ) {
162162 try {
163163 FetchedCatalog fetched = fetchHeads (sourceUrl );
164- Snapshot loadedSnapshot = buildSnapshot (fetched .heads ());
165- this .snapshot = loadedSnapshot ;
164+ Snapshot currentSnapshot = this .snapshot ;
165+ if (!sameHeads (currentSnapshot , fetched .heads ())) {
166+ this .snapshot = buildSnapshot (fetched .heads ());
167+ }
166168 this .catalogRevision = fetched .revision ();
167169 this .activeSource = sourceUrl ;
168- persistCatalogCache (loadedSnapshot .heads (), fetched .revision ());
170+ persistCatalogCache (this . snapshot .heads (), fetched .revision ());
169171
170172 long elapsed = System .currentTimeMillis () - start ;
171173 LOGGER .debug ("Update took {} seconds ({}ms total)" , TimeUnit .MILLISECONDS .toSeconds (elapsed ), elapsed );
172- return loadedSnapshot .heads ();
174+ return this . snapshot .heads ();
173175 } catch (IOException | RuntimeException ex ) {
174176 lastException = ex ;
175177 LOGGER .warn ("Failed to load heads from '{}': {}" , sourceUrl , ex .getMessage ());
@@ -724,6 +726,19 @@ private static boolean sameHead(Head left, Head right) {
724726 && Objects .equals (left .getTags (), right .getTags ());
725727 }
726728
729+ private static boolean sameHeads (@ Nullable Snapshot left , List <Head > right ) {
730+ if (left == null || left .heads ().size () != right .size ()) {
731+ return false ;
732+ }
733+ for (int i = 0 ; i < left .heads ().size (); i ++) {
734+ Head candidate = right .get (i );
735+ if (candidate == null || !sameHead (left .heads ().get (i ), candidate )) {
736+ return false ;
737+ }
738+ }
739+ return true ;
740+ }
741+
727742 private static String rootMessage (Throwable failure ) {
728743 Throwable current = failure ;
729744 while (current .getCause () != null ) current = current .getCause ();
0 commit comments