Browse Source

fix trashing episodes with no title (#773)

pull/775/head
Jason Dove 4 years ago committed by GitHub
parent
commit
4ae671b633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 27
      ErsatzTV.Infrastructure/Search/SearchIndex.cs

3
CHANGELOG.md

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix adding episodes with no title to the search index
- This behavior was preventing some items from being removed from the trash
## [0.5.3-beta] - 2022-04-29
### Fixed

27
ErsatzTV.Infrastructure/Search/SearchIndex.cs

@ -85,7 +85,7 @@ public sealed class SearchIndex : ISearchIndex @@ -85,7 +85,7 @@ public sealed class SearchIndex : ISearchIndex
_initialized = false;
}
public int Version => 22;
public int Version => 23;
public async Task<bool> Initialize(
ILocalFileSystem localFileSystem,
@ -775,23 +775,10 @@ public sealed class SearchIndex : ISearchIndex @@ -775,23 +775,10 @@ public sealed class SearchIndex : ISearchIndex
{
try
{
if (string.IsNullOrWhiteSpace(metadata.Title))
{
_logger.LogWarning(
"Unable to index episode without title {Show} s{Season}e{Episode}",
metadata.Episode.Season?.Show?.ShowMetadata.Head().Title,
metadata.Episode.Season?.SeasonNumber,
metadata.EpisodeNumber);
continue;
}
var doc = new Document
{
new StringField(IdField, episode.Id.ToString(), Field.Store.YES),
new StringField(TypeField, EpisodeType, Field.Store.YES),
new TextField(TitleField, metadata.Title, Field.Store.NO),
new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO),
new TextField(LibraryNameField, episode.LibraryPath.Library.Name, Field.Store.NO),
new StringField(LibraryIdField, episode.LibraryPath.Library.Id.ToString(), Field.Store.NO),
new StringField(TitleAndYearField, GetTitleAndYear(metadata), Field.Store.NO),
@ -802,6 +789,16 @@ public sealed class SearchIndex : ISearchIndex @@ -802,6 +789,16 @@ public sealed class SearchIndex : ISearchIndex
new TextField(ShowTitleField, episode.Season?.Show?.ShowMetadata.Head().Title, Field.Store.NO)
};
if (!string.IsNullOrWhiteSpace(metadata.Title))
{
doc.Add(new TextField(TitleField, metadata.Title, Field.Store.NO));
}
if (!string.IsNullOrWhiteSpace(metadata.SortTitle))
{
doc.Add(new StringField(SortTitleField, metadata.SortTitle.ToLowerInvariant(), Field.Store.NO));
}
await AddLanguages(searchRepository, doc, episode.MediaVersions);
foreach (MediaVersion version in episode.MediaVersions.HeadOrNone())
@ -1023,7 +1020,7 @@ public sealed class SearchIndex : ISearchIndex @@ -1023,7 +1020,7 @@ public sealed class SearchIndex : ISearchIndex
private static string GetJumpLetter(Metadata metadata)
{
char c = metadata.SortTitle.ToLowerInvariant().Head();
char c = (metadata.SortTitle ?? " ").ToLowerInvariant().Head();
return c switch
{
(>= 'a' and <= 'z') => c.ToString(),

Loading…
Cancel
Save