diff options
Diffstat (limited to 'Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs')
| -rw-r--r-- | Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs b/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs index 1c751de1f..b5912788f 100644 --- a/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs +++ b/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs @@ -5,6 +5,7 @@ using MediaBrowser.Model.Drawing; using System; using System.IO; using System.Threading.Tasks; +using MediaBrowser.Common.IO; namespace Emby.Drawing.ImageMagick { @@ -14,12 +15,14 @@ namespace Emby.Drawing.ImageMagick private const int OffsetFromTopRightCorner = 38; private readonly IApplicationPaths _appPaths; - private readonly IHttpClient _iHttpClient; + private readonly IHttpClient _iHttpClient; + private readonly IFileSystem _fileSystem; - public PlayedIndicatorDrawer(IApplicationPaths appPaths, IHttpClient iHttpClient) + public PlayedIndicatorDrawer(IApplicationPaths appPaths, IHttpClient iHttpClient, IFileSystem fileSystem) { _appPaths = appPaths; _iHttpClient = iHttpClient; + _fileSystem = fileSystem; } public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize) @@ -38,7 +41,7 @@ namespace Emby.Drawing.ImageMagick pixel.Opacity = 0; pixel.Color = "white"; draw.FillColor = pixel; - draw.Font = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient).ConfigureAwait(false); + draw.Font = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false); draw.FontSize = FontSize; draw.FontStyle = FontStyleType.NormalStyle; draw.TextAlignment = TextAlignType.CenterAlign; @@ -52,18 +55,18 @@ namespace Emby.Drawing.ImageMagick } } - internal static string ExtractFont(string name, IApplicationPaths paths) + internal static string ExtractFont(string name, IApplicationPaths paths, IFileSystem fileSystem) { var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name); - if (File.Exists(filePath)) + if (fileSystem.FileExists(filePath)) { return filePath; } var namespacePath = typeof(PlayedIndicatorDrawer).Namespace + ".fonts." + name; var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".ttf"); - Directory.CreateDirectory(Path.GetDirectoryName(tempPath)); + fileSystem.CreateDirectory(Path.GetDirectoryName(tempPath)); using (var stream = typeof(PlayedIndicatorDrawer).Assembly.GetManifestResourceStream(namespacePath)) { @@ -73,11 +76,11 @@ namespace Emby.Drawing.ImageMagick } } - Directory.CreateDirectory(Path.GetDirectoryName(filePath)); + fileSystem.CreateDirectory(Path.GetDirectoryName(filePath)); try { - File.Copy(tempPath, filePath, false); + fileSystem.CopyFile(tempPath, filePath, false); } catch (IOException) { @@ -87,11 +90,11 @@ namespace Emby.Drawing.ImageMagick return tempPath; } - internal static async Task<string> DownloadFont(string name, string url, IApplicationPaths paths, IHttpClient httpClient) + internal static async Task<string> DownloadFont(string name, string url, IApplicationPaths paths, IHttpClient httpClient, IFileSystem fileSystem) { var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name); - if (File.Exists(filePath)) + if (fileSystem.FileExists(filePath)) { return filePath; } @@ -103,11 +106,11 @@ namespace Emby.Drawing.ImageMagick }).ConfigureAwait(false); - Directory.CreateDirectory(Path.GetDirectoryName(filePath)); + fileSystem.CreateDirectory(Path.GetDirectoryName(filePath)); try { - File.Copy(tempPath, filePath, false); + fileSystem.CopyFile(tempPath, filePath, false); } catch (IOException) { |
