From cb2c60c9ad82c47cd6fd5f3ad15b0600213e7e0c Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 24 Mar 2021 01:46:00 +0100 Subject: [PATCH] Fixing people & epiosode thumbnails --- Kyoo/Controllers/ThumbnailsManager.cs | 13 ++++++++----- Kyoo/Views/WebClient | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Kyoo/Controllers/ThumbnailsManager.cs b/Kyoo/Controllers/ThumbnailsManager.cs index 04e01ff4..3398f115 100644 --- a/Kyoo/Controllers/ThumbnailsManager.cs +++ b/Kyoo/Controllers/ThumbnailsManager.cs @@ -21,6 +21,8 @@ namespace Kyoo.Controllers _files = files; _peoplePath = Path.GetFullPath(configuration.GetValue("peoplePath")); _providerPath = Path.GetFullPath(configuration.GetValue("providerPath")); + Directory.CreateDirectory(_peoplePath); + Directory.CreateDirectory(_providerPath); } private static async Task DownloadImage(string url, string localPath, string what) @@ -149,10 +151,9 @@ namespace Kyoo.Controllers public Task GetEpisodeThumb(Episode episode) { - return Task.FromResult(Path.Combine( - _files.GetExtraDirectory(episode), - "Thumbnails", - $"{Path.GetFileNameWithoutExtension(episode.Path)}.jpg")); + string dir = Path.Combine(_files.GetExtraDirectory(episode), "Thumbnails"); + Directory.CreateDirectory(dir); + return Task.FromResult(Path.Combine(dir, $"{Path.GetFileNameWithoutExtension(episode.Path)}.jpg")); } public Task GetPeoplePoster(People people) @@ -160,7 +161,7 @@ namespace Kyoo.Controllers if (people == null) throw new ArgumentNullException(nameof(people)); string thumbPath = Path.GetFullPath(Path.Combine(_peoplePath, $"{people.Slug}.jpg")); - if (!thumbPath.StartsWith(_peoplePath) || File.Exists(thumbPath)) + if (!thumbPath.StartsWith(_peoplePath)) return Task.FromResult(null); return Task.FromResult(thumbPath); } @@ -170,6 +171,8 @@ namespace Kyoo.Controllers if (provider == null) throw new ArgumentNullException(nameof(provider)); string thumbPath = Path.GetFullPath(Path.Combine(_providerPath, $"{provider.Slug}.jpg")); + if (!thumbPath.StartsWith(_providerPath)) + return Task.FromResult(null); return Task.FromResult(thumbPath.StartsWith(_providerPath) ? thumbPath : null); } } diff --git a/Kyoo/Views/WebClient b/Kyoo/Views/WebClient index a8a576bd..ab52f039 160000 --- a/Kyoo/Views/WebClient +++ b/Kyoo/Views/WebClient @@ -1 +1 @@ -Subproject commit a8a576bdd9e0c69fbae8e5e4f392c112fe3af8a2 +Subproject commit ab52f039021928cab9f6ed8c17a0488ca198ef74