mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
Merge pull request #831 from Bond-009/hashset
Move some arrays to generics
This commit is contained in:
commit
ee3a4531a0
9 changed files with 37 additions and 37 deletions
|
@ -83,8 +83,8 @@ namespace Emby.Drawing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] SupportedInputFormats =>
|
public IReadOnlyCollection<string> SupportedInputFormats =>
|
||||||
new string[]
|
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"tiff",
|
"tiff",
|
||||||
"tif",
|
"tif",
|
||||||
|
@ -137,14 +137,14 @@ namespace Emby.Drawing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageFormat[] GetSupportedImageOutputFormats()
|
public IReadOnlyCollection<ImageFormat> GetSupportedImageOutputFormats()
|
||||||
{
|
=> _imageEncoder.SupportedOutputFormats;
|
||||||
return _imageEncoder.SupportedOutputFormats;
|
|
||||||
}
|
private static readonly HashSet<string> TransparentImageTypes
|
||||||
|
= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };
|
||||||
|
|
||||||
private static readonly string[] TransparentImageTypes = new string[] { ".png", ".webp", ".gif" };
|
|
||||||
public bool SupportsTransparency(string path)
|
public bool SupportsTransparency(string path)
|
||||||
=> TransparentImageTypes.Contains(Path.GetExtension(path).ToLowerInvariant());
|
=> TransparentImageTypes.Contains(Path.GetExtension(path));
|
||||||
|
|
||||||
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
|
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
|
||||||
{
|
{
|
||||||
|
@ -472,7 +472,7 @@ namespace Emby.Drawing
|
||||||
return (originalImagePath, dateModified);
|
return (originalImagePath, dateModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_imageEncoder.SupportedInputFormats.Contains(inputFormat, StringComparer.OrdinalIgnoreCase))
|
if (!_imageEncoder.SupportedInputFormats.Contains(inputFormat))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
|
|
||||||
|
@ -6,15 +7,11 @@ namespace Emby.Drawing
|
||||||
{
|
{
|
||||||
public class NullImageEncoder : IImageEncoder
|
public class NullImageEncoder : IImageEncoder
|
||||||
{
|
{
|
||||||
public string[] SupportedInputFormats =>
|
public IReadOnlyCollection<string> SupportedInputFormats
|
||||||
new[]
|
=> new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "png", "jpeg", "jpg" };
|
||||||
{
|
|
||||||
"png",
|
|
||||||
"jpeg",
|
|
||||||
"jpg"
|
|
||||||
};
|
|
||||||
|
|
||||||
public ImageFormat[] SupportedOutputFormats => new[] { ImageFormat.Jpg, ImageFormat.Png };
|
public IReadOnlyCollection<ImageFormat> SupportedOutputFormats
|
||||||
|
=> new HashSet<ImageFormat>() { ImageFormat.Jpg, ImageFormat.Png };
|
||||||
|
|
||||||
public void CropWhiteSpace(string inputPath, string outputPath)
|
public void CropWhiteSpace(string inputPath, string outputPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.IO
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Any file name ending in any of these will be ignored by the watchers
|
/// Any file name ending in any of these will be ignored by the watchers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly string[] _alwaysIgnoreFiles = new string[]
|
private readonly HashSet<string> _alwaysIgnoreFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"small.jpg",
|
"small.jpg",
|
||||||
"albumart.jpg",
|
"albumart.jpg",
|
||||||
|
@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.IO
|
||||||
".actors"
|
".actors"
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly string[] _alwaysIgnoreExtensions = new string[]
|
private readonly HashSet<string> _alwaysIgnoreExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
// thumbs.db
|
// thumbs.db
|
||||||
".db",
|
".db",
|
||||||
|
@ -456,8 +456,8 @@ namespace Emby.Server.Implementations.IO
|
||||||
var filename = Path.GetFileName(path);
|
var filename = Path.GetFileName(path);
|
||||||
|
|
||||||
var monitorPath = !string.IsNullOrEmpty(filename) &&
|
var monitorPath = !string.IsNullOrEmpty(filename) &&
|
||||||
!_alwaysIgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase) &&
|
!_alwaysIgnoreFiles.Contains(filename) &&
|
||||||
!_alwaysIgnoreExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
|
!_alwaysIgnoreExtensions.Contains(Path.GetExtension(path)) &&
|
||||||
_alwaysIgnoreSubstrings.All(i => path.IndexOf(i, StringComparison.OrdinalIgnoreCase) == -1);
|
_alwaysIgnoreSubstrings.All(i => path.IndexOf(i, StringComparison.OrdinalIgnoreCase) == -1);
|
||||||
|
|
||||||
// Ignore certain files
|
// Ignore certain files
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
|
@ -85,7 +86,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly string[] IgnoreFiles =
|
private static readonly HashSet<string> IgnoreFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"folder",
|
"folder",
|
||||||
"thumb",
|
"thumb",
|
||||||
|
@ -102,7 +103,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||||
{
|
{
|
||||||
var filename = Path.GetFileNameWithoutExtension(path) ?? string.Empty;
|
var filename = Path.GetFileNameWithoutExtension(path) ?? string.Empty;
|
||||||
|
|
||||||
if (IgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase))
|
if (IgnoreFiles.Contains(filename))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +113,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageProcessor.SupportedInputFormats.Contains((Path.GetExtension(path) ?? string.Empty).TrimStart('.'), StringComparer.OrdinalIgnoreCase);
|
return imageProcessor.SupportedInputFormats.Contains((Path.GetExtension(path) ?? string.Empty).TrimStart('.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Services
|
||||||
response.ContentType = defaultContentType;
|
response.ContentType = defaultContentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new HashSet<string> { "application/json", }.Contains(response.ContentType))
|
if (response.ContentType == "application/json")
|
||||||
{
|
{
|
||||||
response.ContentType += "; charset=utf-8";
|
response.ContentType += "; charset=utf-8";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace Emby.Server.Implementations.Services
|
||||||
"POLL", "SUBSCRIBE", "UNSUBSCRIBE"
|
"POLL", "SUBSCRIBE", "UNSUBSCRIBE"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static HashSet<string> AllVerbsSet = new HashSet<string>(AllVerbs);
|
|
||||||
|
|
||||||
public static List<MethodInfo> GetActions(this Type serviceType)
|
public static List<MethodInfo> GetActions(this Type serviceType)
|
||||||
{
|
{
|
||||||
var list = new List<MethodInfo>();
|
var list = new List<MethodInfo>();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -35,8 +36,8 @@ namespace Jellyfin.Drawing.Skia
|
||||||
LogVersion();
|
LogVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] SupportedInputFormats =>
|
public IReadOnlyCollection<string> SupportedInputFormats =>
|
||||||
new[]
|
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"jpeg",
|
"jpeg",
|
||||||
"jpg",
|
"jpg",
|
||||||
|
@ -62,7 +63,8 @@ namespace Jellyfin.Drawing.Skia
|
||||||
"arw"
|
"arw"
|
||||||
};
|
};
|
||||||
|
|
||||||
public ImageFormat[] SupportedOutputFormats => new[] { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png };
|
public IReadOnlyCollection<ImageFormat> SupportedOutputFormats
|
||||||
|
=> new HashSet<ImageFormat>() { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png };
|
||||||
|
|
||||||
private void LogVersion()
|
private void LogVersion()
|
||||||
{
|
{
|
||||||
|
@ -253,7 +255,8 @@ namespace Jellyfin.Drawing.Skia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string[] TransparentImageTypes = new string[] { ".png", ".gif", ".webp" };
|
private static readonly HashSet<string> TransparentImageTypes
|
||||||
|
= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".gif", ".webp" };
|
||||||
|
|
||||||
internal static SKBitmap Decode(string path, bool forceCleanBitmap, IFileSystem fileSystem, ImageOrientation? orientation, out SKEncodedOrigin origin)
|
internal static SKBitmap Decode(string path, bool forceCleanBitmap, IFileSystem fileSystem, ImageOrientation? orientation, out SKEncodedOrigin origin)
|
||||||
{
|
{
|
||||||
|
@ -262,7 +265,7 @@ namespace Jellyfin.Drawing.Skia
|
||||||
throw new FileNotFoundException("File not found", path);
|
throw new FileNotFoundException("File not found", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
var requiresTransparencyHack = TransparentImageTypes.Contains(Path.GetExtension(path) ?? string.Empty);
|
var requiresTransparencyHack = TransparentImageTypes.Contains(Path.GetExtension(path));
|
||||||
|
|
||||||
if (requiresTransparencyHack || forceCleanBitmap)
|
if (requiresTransparencyHack || forceCleanBitmap)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Drawing
|
namespace MediaBrowser.Controller.Drawing
|
||||||
|
@ -9,12 +10,12 @@ namespace MediaBrowser.Controller.Drawing
|
||||||
/// Gets the supported input formats.
|
/// Gets the supported input formats.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The supported input formats.</value>
|
/// <value>The supported input formats.</value>
|
||||||
string[] SupportedInputFormats { get; }
|
IReadOnlyCollection<string> SupportedInputFormats { get; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the supported output formats.
|
/// Gets the supported output formats.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The supported output formats.</value>
|
/// <value>The supported output formats.</value>
|
||||||
ImageFormat[] SupportedOutputFormats { get; }
|
IReadOnlyCollection<ImageFormat> SupportedOutputFormats { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encodes the image.
|
/// Encodes the image.
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||||
/// Gets the supported input formats.
|
/// Gets the supported input formats.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The supported input formats.</value>
|
/// <value>The supported input formats.</value>
|
||||||
string[] SupportedInputFormats { get; }
|
IReadOnlyCollection<string> SupportedInputFormats { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the image enhancers.
|
/// Gets the image enhancers.
|
||||||
|
@ -96,8 +96,8 @@ namespace MediaBrowser.Controller.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the supported image output formats.
|
/// Gets the supported image output formats.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>ImageOutputFormat[].</returns>
|
/// <returns>IReadOnlyCollection{ImageOutput}.</returns>
|
||||||
ImageFormat[] GetSupportedImageOutputFormats();
|
IReadOnlyCollection<ImageFormat> GetSupportedImageOutputFormats();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the image collage.
|
/// Creates the image collage.
|
||||||
|
|
Loading…
Reference in a new issue