fix incorrect search items count (#224)

This commit is contained in:
Jason Dove
2021-05-28 06:13:40 -05:00
committed by GitHub
parent 95cceb95b9
commit 4c78f41c5a
8 changed files with 10 additions and 1 deletions
@@ -36,6 +36,7 @@ namespace ErsatzTV.Application.Emby.Commands
{ {
List<int> ids = await _mediaSourceRepository.DeleteAllEmby(); List<int> ids = await _mediaSourceRepository.DeleteAllEmby();
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
await _embySecretStore.DeleteAll(); await _embySecretStore.DeleteAll();
_entityLocker.UnlockRemoteMediaSource<EmbyMediaSource>(); _entityLocker.UnlockRemoteMediaSource<EmbyMediaSource>();
@@ -31,6 +31,7 @@ namespace ErsatzTV.Application.Emby.Commands
var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList(); var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList();
List<int> ids = await _mediaSourceRepository.DisableEmbyLibrarySync(toDisable); List<int> ids = await _mediaSourceRepository.DisableEmbyLibrarySync(toDisable);
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
IEnumerable<int> toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id); IEnumerable<int> toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id);
await _mediaSourceRepository.EnableEmbyLibrarySync(toEnable); await _mediaSourceRepository.EnableEmbyLibrarySync(toEnable);
@@ -36,6 +36,7 @@ namespace ErsatzTV.Application.Jellyfin.Commands
{ {
List<int> ids = await _mediaSourceRepository.DeleteAllJellyfin(); List<int> ids = await _mediaSourceRepository.DeleteAllJellyfin();
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
await _jellyfinSecretStore.DeleteAll(); await _jellyfinSecretStore.DeleteAll();
_entityLocker.UnlockRemoteMediaSource<JellyfinMediaSource>(); _entityLocker.UnlockRemoteMediaSource<JellyfinMediaSource>();
@@ -31,6 +31,7 @@ namespace ErsatzTV.Application.Jellyfin.Commands
var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList(); var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList();
List<int> ids = await _mediaSourceRepository.DisableJellyfinLibrarySync(toDisable); List<int> ids = await _mediaSourceRepository.DisableJellyfinLibrarySync(toDisable);
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
IEnumerable<int> toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id); IEnumerable<int> toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id);
await _mediaSourceRepository.EnableJellyfinLibrarySync(toEnable); await _mediaSourceRepository.EnableJellyfinLibrarySync(toEnable);
@@ -32,6 +32,7 @@ namespace ErsatzTV.Application.Libraries.Commands
{ {
List<int> ids = await _libraryRepository.GetMediaIdsByLocalPath(libraryPath.Id); List<int> ids = await _libraryRepository.GetMediaIdsByLocalPath(libraryPath.Id);
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
await _libraryRepository.DeleteLocalPath(libraryPath.Id); await _libraryRepository.DeleteLocalPath(libraryPath.Id);
return Unit.Default; return Unit.Default;
} }
@@ -33,6 +33,7 @@ namespace ErsatzTV.Application.Plex.Commands
{ {
List<int> ids = await _mediaSourceRepository.DeleteAllPlex(); List<int> ids = await _mediaSourceRepository.DeleteAllPlex();
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
await _plexSecretStore.DeleteAll(); await _plexSecretStore.DeleteAll();
_entityLocker.UnlockPlex(); _entityLocker.UnlockPlex();
@@ -31,6 +31,7 @@ namespace ErsatzTV.Application.Plex.Commands
var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList(); var toDisable = request.Preferences.Filter(p => p.ShouldSyncItems == false).Map(p => p.Id).ToList();
List<int> ids = await _mediaSourceRepository.DisablePlexLibrarySync(toDisable); List<int> ids = await _mediaSourceRepository.DisablePlexLibrarySync(toDisable);
await _searchIndex.RemoveItems(ids); await _searchIndex.RemoveItems(ids);
_searchIndex.Commit();
IEnumerable<int> toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id); IEnumerable<int> toEnable = request.Preferences.Filter(p => p.ShouldSyncItems).Map(p => p.Id);
await _mediaSourceRepository.EnablePlexLibrarySync(toEnable); await _mediaSourceRepository.EnablePlexLibrarySync(toEnable);
@@ -71,7 +71,7 @@ namespace ErsatzTV.Infrastructure.Search
_initialized = false; _initialized = false;
} }
public int Version => 11; public int Version => 12;
public Task<bool> Initialize(ILocalFileSystem localFileSystem) public Task<bool> Initialize(ILocalFileSystem localFileSystem)
{ {
@@ -92,6 +92,8 @@ namespace ErsatzTV.Infrastructure.Search
public async Task<Unit> Rebuild(ISearchRepository searchRepository, List<int> itemIds) public async Task<Unit> Rebuild(ISearchRepository searchRepository, List<int> itemIds)
{ {
_writer.DeleteAll();
foreach (int id in itemIds) foreach (int id in itemIds)
{ {
Option<MediaItem> maybeMediaItem = await searchRepository.GetItemToIndex(id); Option<MediaItem> maybeMediaItem = await searchRepository.GetItemToIndex(id);