diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 6d71e99a1..48d24385e 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -669,7 +669,7 @@ namespace Emby.Server.Implementations.Library if (parent is not null) { - var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType().ToArray(); + var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType(); foreach (var resolver in multiItemResolvers) { diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs index 90035f18f..5d65b0f9b 100644 --- a/MediaBrowser.Model/Net/MimeTypes.cs +++ b/MediaBrowser.Model/Net/MimeTypes.cs @@ -1,6 +1,7 @@ #pragma warning disable CS1591 using System; +using System.Collections.Frozen; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -26,7 +27,7 @@ namespace MediaBrowser.Model.Net /// /// Any extension in this list is considered a video file. /// - private static readonly HashSet _videoFileExtensions = new HashSet(StringComparer.OrdinalIgnoreCase) + private static readonly FrozenSet _videoFileExtensions = new[] { ".3gp", ".asf", @@ -57,90 +58,90 @@ namespace MediaBrowser.Model.Net ".webm", ".wmv", ".wtv", - }; + }.ToFrozenSet(StringComparer.OrdinalIgnoreCase); /// /// Used for extensions not in or to override them. /// - private static readonly Dictionary _mimeTypeLookup = new Dictionary(StringComparer.OrdinalIgnoreCase) + private static readonly FrozenDictionary _mimeTypeLookup = new KeyValuePair[] { // Type application - { ".azw3", "application/vnd.amazon.ebook" }, - { ".cb7", "application/x-cb7" }, - { ".cba", "application/x-cba" }, - { ".cbr", "application/vnd.comicbook-rar" }, - { ".cbt", "application/x-cbt" }, - { ".cbz", "application/vnd.comicbook+zip" }, + new(".azw3", "application/vnd.amazon.ebook"), + new(".cb7", "application/x-cb7"), + new(".cba", "application/x-cba"), + new(".cbr", "application/vnd.comicbook-rar"), + new(".cbt", "application/x-cbt"), + new(".cbz", "application/vnd.comicbook+zip"), // Type image - { ".tbn", "image/jpeg" }, + new(".tbn", "image/jpeg"), // Type text - { ".ass", "text/x-ssa" }, - { ".ssa", "text/x-ssa" }, - { ".edl", "text/plain" }, - { ".html", "text/html; charset=UTF-8" }, - { ".htm", "text/html; charset=UTF-8" }, + new(".ass", "text/x-ssa"), + new(".ssa", "text/x-ssa"), + new(".edl", "text/plain"), + new(".html", "text/html; charset=UTF-8"), + new(".htm", "text/html; charset=UTF-8"), // Type video - { ".mpegts", "video/mp2t" }, + new(".mpegts", "video/mp2t"), // Type audio - { ".aac", "audio/aac" }, - { ".ac3", "audio/ac3" }, - { ".ape", "audio/x-ape" }, - { ".dsf", "audio/dsf" }, - { ".dsp", "audio/dsp" }, - { ".flac", "audio/flac" }, - { ".m4b", "audio/mp4" }, - { ".mp3", "audio/mpeg" }, - { ".vorbis", "audio/vorbis" }, - { ".webma", "audio/webm" }, - { ".wv", "audio/x-wavpack" }, - { ".xsp", "audio/xsp" }, - }; + new(".aac", "audio/aac"), + new(".ac3", "audio/ac3"), + new(".ape", "audio/x-ape"), + new(".dsf", "audio/dsf"), + new(".dsp", "audio/dsp"), + new(".flac", "audio/flac"), + new(".m4b", "audio/mp4"), + new(".mp3", "audio/mpeg"), + new(".vorbis", "audio/vorbis"), + new(".webma", "audio/webm"), + new(".wv", "audio/x-wavpack"), + new(".xsp", "audio/xsp"), + }.ToFrozenDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase); - private static readonly Dictionary _extensionLookup = new Dictionary(StringComparer.OrdinalIgnoreCase) + private static readonly FrozenDictionary _extensionLookup = new KeyValuePair[] { // Type application - { "application/vnd.comicbook-rar", ".cbr" }, - { "application/vnd.comicbook+zip", ".cbz" }, - { "application/x-cb7", ".cb7" }, - { "application/x-cba", ".cba" }, - { "application/x-cbr", ".cbr" }, - { "application/x-cbt", ".cbt" }, - { "application/x-cbz", ".cbz" }, - { "application/x-javascript", ".js" }, - { "application/xml", ".xml" }, - { "application/x-mpegURL", ".m3u8" }, + new("application/vnd.comicbook-rar", ".cbr"), + new("application/vnd.comicbook+zip", ".cbz"), + new("application/x-cb7", ".cb7"), + new("application/x-cba", ".cba"), + new("application/x-cbr", ".cbr"), + new("application/x-cbt", ".cbt"), + new("application/x-cbz", ".cbz"), + new("application/x-javascript", ".js"), + new("application/xml", ".xml"), + new("application/x-mpegURL", ".m3u8"), // Type audio - { "audio/aac", ".aac" }, - { "audio/ac3", ".ac3" }, - { "audio/dsf", ".dsf" }, - { "audio/dsp", ".dsp" }, - { "audio/flac", ".flac" }, - { "audio/m4b", ".m4b" }, - { "audio/vorbis", ".vorbis" }, - { "audio/x-ape", ".ape" }, - { "audio/xsp", ".xsp" }, - { "audio/x-wavpack", ".wv" }, + new("audio/aac", ".aac"), + new("audio/ac3", ".ac3"), + new("audio/dsf", ".dsf"), + new("audio/dsp", ".dsp"), + new("audio/flac", ".flac"), + new("audio/m4b", ".m4b"), + new("audio/vorbis", ".vorbis"), + new("audio/x-ape", ".ape"), + new("audio/xsp", ".xsp"), + new("audio/x-wavpack", ".wv"), // Type image - { "image/jpeg", ".jpg" }, - { "image/tiff", ".tiff" }, - { "image/x-png", ".png" }, - { "image/x-icon", ".ico" }, + new("image/jpeg", ".jpg"), + new("image/tiff", ".tiff"), + new("image/x-png", ".png"), + new("image/x-icon", ".ico"), // Type text - { "text/plain", ".txt" }, - { "text/rtf", ".rtf" }, - { "text/x-ssa", ".ssa" }, + new("text/plain", ".txt"), + new("text/rtf", ".rtf"), + new("text/x-ssa", ".ssa"), // Type video - { "video/vnd.mpeg.dash.mpd", ".mpd" }, - { "video/x-matroska", ".mkv" }, - }; + new("video/vnd.mpeg.dash.mpd", ".mpd"), + new("video/x-matroska", ".mkv"), + }.ToFrozenDictionary(pair => pair.Key, pair => pair.Value, StringComparer.OrdinalIgnoreCase); public static string GetMimeType(string path) => GetMimeType(path, "application/octet-stream");