Compare commits

..

No commits in common. "4772ae075647a11555b0a8e6ddd23f97351a8667" and "6aa0ea277b891c2d5fd321f4383d14b0754b8e81" have entirely different histories.

2 changed files with 7 additions and 10 deletions

View File

@ -100,8 +100,10 @@ public class MangaDex : Connector
string? coverUrl = GetCoverUrl(publicationId, posterId);
string? coverCacheName = null;
if (coverUrl is not null)
coverCacheName = SaveImage(coverUrl);
{
DownloadClient.RequestResult coverResult = downloadClient.MakeRequest(coverUrl, (byte)RequestType.AtHomeServer);
coverCacheName = SaveImage(coverUrl, coverResult.result);
}
string? author = GetAuthor(authorId);
Dictionary<string, string> linksDict = new();
@ -298,18 +300,13 @@ public class MangaDex : Connector
DownloadImage(publication.posterUrl, Path.Join(downloadLocation, publication.folderName, $"cover.{extension}"), this.downloadClient, (byte)RequestType.AtHomeServer);
}
private string SaveImage(string url)
private string SaveImage(string url, Stream imageData)
{
string[] split = url.Split('/');
string filename = split[^1];
string saveImagePath = Path.Join(imageCachePath, filename);
if (File.Exists(saveImagePath))
return saveImagePath;
DownloadClient.RequestResult coverResult = downloadClient.MakeRequest(url, (byte)RequestType.AtHomeServer);
using MemoryStream ms = new();
coverResult.result.CopyTo(ms);
imageData.CopyTo(ms);
File.WriteAllBytes(saveImagePath, ms.ToArray());
return filename;
}

View File

@ -14,4 +14,4 @@
ports:
- 9555:80
volumes:
- ./tranga/imageCache:/usr/share/nginx/html/imageCache:ro #2 when replacing Point to same value as #1/imageCache
- ./tranga/imageCache:/usr/share/nginx/html/imageCache #2 when replacing Point to same value as #1/imageCache