2
0

Merge branch 'refs/heads/cuttingedge-merge-ServerV2' into Server-V2

# Conflicts:
#	Tranga/Jobs/JobBoss.cs
This commit is contained in:
Glax 2024-05-26 18:56:30 +02:00
commit 5c309131ad
2 changed files with 5 additions and 7 deletions

View File

@ -192,13 +192,10 @@ public class JobBoss : GlobalBase
foreach (string internalId in extraneousIds) foreach (string internalId in extraneousIds)
RemoveMangaFromCache(internalId); RemoveMangaFromCache(internalId);
HashSet<string> coverFileNames = GetAllCachedManga().Select(manga => manga.coverFileNameInCache!).ToHashSet(); string[] coverFiles = Directory.GetFiles(settings.coverImageCache);
foreach (string fileName in Directory.GetFiles(settings.coverImageCache)) //Cleanup Unused Covers foreach(string fileName in coverFiles.Where(fileName => !GetAllCachedManga().Any(manga => manga.coverFileNameInCache == fileName)))
{
if(!coverFileNames.Any(existingManga => fileName.Contains(existingManga)))
File.Delete(fileName); File.Delete(fileName);
} }
}
internal void UpdateJobFile(Job job, string? oldFile = null) internal void UpdateJobFile(Job job, string? oldFile = null)
{ {

View File

@ -287,8 +287,9 @@ public abstract class MangaConnector : GlobalBase
protected string SaveCoverImageToCache(string url, RequestType requestType) protected string SaveCoverImageToCache(string url, RequestType requestType)
{ {
string filetype = url.Split('/')[^1].Split('?')[0].Split('.')[^1]; Regex urlRex = new (@"https?:\/\/((?:[a-zA-Z0-9]+\.)+[a-zA-Z]+)\/(?:.+\/)*(.+\.[a-zA-Z]+)");
string filename = $"{DateTime.Now.Ticks.ToString()}.{filetype}"; Match match = urlRex.Match(url);
string filename = $"{match.Groups[1].Value}-{match.Groups[2].Value}";
string saveImagePath = Path.Join(settings.coverImageCache, filename); string saveImagePath = Path.Join(settings.coverImageCache, filename);
if (File.Exists(saveImagePath)) if (File.Exists(saveImagePath))