Compare each side of a data source edit with its own provider

This commit is contained in:
Thorsten Sommer committed 2026-09-18 18:04:43 +02:00
1 parent 6012f18e85
commit 946ae1a5a5
3 files changed
+98 -16

No files matched your search

@@ -28,13 +28,20 @@ internal static class EmbeddingChangeImpact
/// <summary>
/// Whether an edited data source invalidates what is stored for it.
/// </summary>
/// <param name="embeddingProvider">The embedding provider, which the edit leaves alone.</param>
/// <remarks>
/// Each side is asked with the embedding provider it points at, never both with the same one. A
/// data source carries only the id of its provider, while the signature carries what that provider
/// is, so comparing both sides against one of them would report a changed embedding as no change
/// at all -- and the next indexing run would then rebuild everything unannounced.
/// </remarks>
/// <param name="before">The data source as it is stored.</param>
/// <param name="beforeProvider">The embedding provider it points at today.</param>
/// <param name="after">The data source as it would be stored.</param>
/// <param name="afterProvider">The embedding provider it would point at.</param>
/// <returns>True when the stored index would be discarded.</returns>
public static bool AffectsStoredIndex(EmbeddingProvider embeddingProvider, IDataSource before, IDataSource after) =>
public static bool AffectsStoredIndex(IDataSource before, EmbeddingProvider beforeProvider, IDataSource after, EmbeddingProvider afterProvider) =>
!string.Equals(
DataSourceEmbeddingService.BuildEmbeddingSignature(before, embeddingProvider),
DataSourceEmbeddingService.BuildEmbeddingSignature(after, embeddingProvider),
DataSourceEmbeddingService.BuildEmbeddingSignature(before, beforeProvider),
DataSourceEmbeddingService.BuildEmbeddingSignature(after, afterProvider),
StringComparison.Ordinal);
}