diff --git a/ErsatzTV.Application/Emby/Commands/DisconnectEmbyHandler.cs b/ErsatzTV.Application/Emby/Commands/DisconnectEmbyHandler.cs index 1d3ed99a8..0e950cd85 100644 --- a/ErsatzTV.Application/Emby/Commands/DisconnectEmbyHandler.cs +++ b/ErsatzTV.Application/Emby/Commands/DisconnectEmbyHandler.cs @@ -36,6 +36,7 @@ namespace ErsatzTV.Application.Emby.Commands { List ids = await _mediaSourceRepository.DeleteAllEmby(); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); await _embySecretStore.DeleteAll(); _entityLocker.UnlockRemoteMediaSource(); diff --git a/ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferencesHandler.cs b/ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferencesHandler.cs index 09bc158b3..273f320b2 100644 --- a/ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferencesHandler.cs +++ b/ErsatzTV.Application/Emby/Commands/UpdateEmbyLibraryPreferencesHandler.cs @@ -31,6 +31,7 @@ namespace ErsatzTV.Application.Emby.Commands var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList(); List ids = await _mediaSourceRepository.DisableEmbyLibrarySync(toDisable); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); IEnumerable toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id); await _mediaSourceRepository.EnableEmbyLibrarySync(toEnable); diff --git a/ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfinHandler.cs b/ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfinHandler.cs index ec5246700..26452d3e4 100644 --- a/ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfinHandler.cs +++ b/ErsatzTV.Application/Jellyfin/Commands/DisconnectJellyfinHandler.cs @@ -36,6 +36,7 @@ namespace ErsatzTV.Application.Jellyfin.Commands { List ids = await _mediaSourceRepository.DeleteAllJellyfin(); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); await _jellyfinSecretStore.DeleteAll(); _entityLocker.UnlockRemoteMediaSource(); diff --git a/ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferencesHandler.cs b/ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferencesHandler.cs index 5d5c74f8e..4060af789 100644 --- a/ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferencesHandler.cs +++ b/ErsatzTV.Application/Jellyfin/Commands/UpdateJellyfinLibraryPreferencesHandler.cs @@ -31,6 +31,7 @@ namespace ErsatzTV.Application.Jellyfin.Commands var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList(); List ids = await _mediaSourceRepository.DisableJellyfinLibrarySync(toDisable); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); IEnumerable toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id); await _mediaSourceRepository.EnableJellyfinLibrarySync(toEnable); diff --git a/ErsatzTV.Application/Libraries/Commands/DeleteLocalLibraryPathHandler.cs b/ErsatzTV.Application/Libraries/Commands/DeleteLocalLibraryPathHandler.cs index d6935f3f7..90e64d5cd 100644 --- a/ErsatzTV.Application/Libraries/Commands/DeleteLocalLibraryPathHandler.cs +++ b/ErsatzTV.Application/Libraries/Commands/DeleteLocalLibraryPathHandler.cs @@ -32,6 +32,7 @@ namespace ErsatzTV.Application.Libraries.Commands { List ids = await _libraryRepository.GetMediaIdsByLocalPath(libraryPath.Id); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); await _libraryRepository.DeleteLocalPath(libraryPath.Id); return Unit.Default; } diff --git a/ErsatzTV.Application/Plex/Commands/SignOutOfPlexHandler.cs b/ErsatzTV.Application/Plex/Commands/SignOutOfPlexHandler.cs index 00d072b29..3d4227230 100644 --- a/ErsatzTV.Application/Plex/Commands/SignOutOfPlexHandler.cs +++ b/ErsatzTV.Application/Plex/Commands/SignOutOfPlexHandler.cs @@ -33,6 +33,7 @@ namespace ErsatzTV.Application.Plex.Commands { List ids = await _mediaSourceRepository.DeleteAllPlex(); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); await _plexSecretStore.DeleteAll(); _entityLocker.UnlockPlex(); diff --git a/ErsatzTV.Application/Plex/Commands/UpdatePlexLibraryPreferencesHandler.cs b/ErsatzTV.Application/Plex/Commands/UpdatePlexLibraryPreferencesHandler.cs index b7eea5bd2..fdd3355d1 100644 --- a/ErsatzTV.Application/Plex/Commands/UpdatePlexLibraryPreferencesHandler.cs +++ b/ErsatzTV.Application/Plex/Commands/UpdatePlexLibraryPreferencesHandler.cs @@ -31,6 +31,7 @@ namespace ErsatzTV.Application.Plex.Commands var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList(); List ids = await _mediaSourceRepository.DisablePlexLibrarySync(toDisable); await _searchIndex.RemoveItems(ids); + _searchIndex.Commit(); IEnumerable toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id); await _mediaSourceRepository.EnablePlexLibrarySync(toEnable); diff --git a/ErsatzTV.Infrastructure/Search/SearchIndex.cs b/ErsatzTV.Infrastructure/Search/SearchIndex.cs index 3375c9a16..f4957eff6 100644 --- a/ErsatzTV.Infrastructure/Search/SearchIndex.cs +++ b/ErsatzTV.Infrastructure/Search/SearchIndex.cs @@ -71,7 +71,7 @@ namespace ErsatzTV.Infrastructure.Search _initialized = false; } - public int Version => 11; + public int Version => 12; public Task Initialize(ILocalFileSystem localFileSystem) { @@ -92,6 +92,8 @@ namespace ErsatzTV.Infrastructure.Search public async Task Rebuild(ISearchRepository searchRepository, List itemIds) { + _writer.DeleteAll(); + foreach (int id in itemIds) { Option maybeMediaItem = await searchRepository.GetItemToIndex(id);