Merge branch 'refs/heads/cuttingedge-merge-ServerV2' into cuttingedge
This commit is contained in:
commit
fdea3659f1
@ -8,13 +8,12 @@ namespace Tranga.MangaConnectors;
|
||||
|
||||
internal class ChromiumDownloadClient : DownloadClient
|
||||
{
|
||||
private IBrowser browser { get; set; }
|
||||
private const int StartTimeoutMs = 30000;
|
||||
private static readonly IBrowser Browser = StartBrowser().Result;
|
||||
private const int StartTimeoutMs = 10000;
|
||||
private readonly HttpDownloadClient _httpDownloadClient;
|
||||
|
||||
private async Task<IBrowser> StartBrowser()
|
||||
private static async Task<IBrowser> StartBrowser()
|
||||
{
|
||||
Log($"Starting Browser. ({StartTimeoutMs}ms timeout)");
|
||||
return await Puppeteer.LaunchAsync(new LaunchOptions
|
||||
{
|
||||
Headless = true,
|
||||
@ -29,7 +28,6 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
|
||||
public ChromiumDownloadClient(GlobalBase clone) : base(clone)
|
||||
{
|
||||
this.browser = StartBrowser().Result;
|
||||
_httpDownloadClient = new(this);
|
||||
}
|
||||
|
||||
@ -43,7 +41,7 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
|
||||
private RequestResult MakeRequestBrowser(string url, string? referrer = null, string? clickButton = null)
|
||||
{
|
||||
IPage page = this.browser.NewPageAsync().Result;
|
||||
IPage page = Browser.NewPageAsync().Result;
|
||||
page.DefaultTimeout = 10000;
|
||||
IResponse response;
|
||||
try
|
||||
@ -54,6 +52,7 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
catch (Exception e)
|
||||
{
|
||||
Log($"Could not load Page:\n{e.Message}");
|
||||
page.CloseAsync();
|
||||
return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null);
|
||||
}
|
||||
|
||||
@ -84,9 +83,4 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
page.CloseAsync();
|
||||
return new RequestResult(response.Status, document, stream, false, "");
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
this.browser.CloseAsync();
|
||||
}
|
||||
}
|
@ -41,5 +41,4 @@ internal abstract class DownloadClient : GlobalBase
|
||||
}
|
||||
|
||||
internal abstract RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null);
|
||||
public abstract void Close();
|
||||
}
|
@ -72,9 +72,4 @@ internal class HttpDownloadClient : DownloadClient
|
||||
|
||||
return new RequestResult(response.StatusCode, document, stream);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
Log("Closing.");
|
||||
}
|
||||
}
|
@ -15,11 +15,6 @@ public abstract class MangaConnector : GlobalBase
|
||||
{
|
||||
internal DownloadClient downloadClient { get; init; } = null!;
|
||||
|
||||
public void StopDownloadClient()
|
||||
{
|
||||
downloadClient.Close();
|
||||
}
|
||||
|
||||
protected MangaConnector(GlobalBase clone, string name) : base(clone)
|
||||
{
|
||||
this.name = name;
|
||||
@ -234,7 +229,10 @@ public abstract class MangaConnector : GlobalBase
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
if (File.Exists(saveArchiveFilePath)) //Don't download twice.
|
||||
{
|
||||
progressToken?.Complete();
|
||||
return HttpStatusCode.Created;
|
||||
}
|
||||
|
||||
//Create a temporary folder to store images
|
||||
string tempFolder = Directory.CreateTempSubdirectory("trangatemp").FullName;
|
||||
|
Loading…
Reference in New Issue
Block a user