diff options
| author | Bond_009 <bond.009@outlook.com> | 2021-02-24 02:34:50 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2021-02-24 02:57:10 +0100 |
| commit | 1c74e2f40e6790621ebc06dd37083a29be2459bd (patch) | |
| tree | 0789c05d4ac224b2197bed7dc9564b98a23b3ad6 /Emby.Server.Implementations/Library/LibraryManager.cs | |
| parent | 914e891689af38911332d14b18b4a1b4834cd9ae (diff) | |
Fix build
Diffstat (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Library/LibraryManager.cs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 03da1add8..799f8abc3 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1240,11 +1240,20 @@ namespace Emby.Server.Implementations.Library return info; } - private string GetCollectionType(string path) + private CollectionTypeOptions GetCollectionType(string path) { - return _fileSystem.GetFilePaths(path, new[] { ".collection" }, true, false) - .Select(Path.GetFileNameWithoutExtension) - .FirstOrDefault(i => !string.IsNullOrEmpty(i)); + var files = _fileSystem.GetFilePaths(path, new[] { ".collection" }, true, false); + foreach (var file in files) + { + // TODO: @bond use a ReadOnlySpan<char> here when Enum.TryParse supports it + // https://github.com/dotnet/runtime/issues/20008 + if (Enum.TryParse<CollectionTypeOptions>(Path.GetExtension(file), true, out var res)) + { + return res; + } + } + + throw new FileNotFoundException("Coudn't find an appropriate collection type file."); } /// <summary> |
