#62 more debug-logging
Instead of assigning buffer copy directy from result to filestream
This commit is contained in:
parent
17b6c523a2
commit
c69dd22ecf
@ -30,7 +30,10 @@ internal abstract class DownloadClient : GlobalBase
|
|||||||
.Subtract(DateTime.Now.Subtract(_lastExecutedRateLimit[requestType]));
|
.Subtract(DateTime.Now.Subtract(_lastExecutedRateLimit[requestType]));
|
||||||
|
|
||||||
if (rateLimitTimeout > TimeSpan.Zero)
|
if (rateLimitTimeout > TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
Log($"Waiting {rateLimitTimeout.TotalSeconds} seconds");
|
||||||
Thread.Sleep(rateLimitTimeout);
|
Thread.Sleep(rateLimitTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
RequestResult result = MakeRequestInternal(url, referrer);
|
RequestResult result = MakeRequestInternal(url, referrer);
|
||||||
_lastExecutedRateLimit[requestType] = DateTime.Now;
|
_lastExecutedRateLimit[requestType] = DateTime.Now;
|
||||||
|
@ -175,11 +175,15 @@ public abstract class MangaConnector : GlobalBase
|
|||||||
private HttpStatusCode DownloadImage(string imageUrl, string fullPath, byte requestType, string? referrer = null)
|
private HttpStatusCode DownloadImage(string imageUrl, string fullPath, byte requestType, string? referrer = null)
|
||||||
{
|
{
|
||||||
DownloadClient.RequestResult requestResult = downloadClient.MakeRequest(imageUrl, requestType, referrer);
|
DownloadClient.RequestResult requestResult = downloadClient.MakeRequest(imageUrl, requestType, referrer);
|
||||||
if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300 || requestResult.result == Stream.Null)
|
|
||||||
|
if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300)
|
||||||
return requestResult.statusCode;
|
return requestResult.statusCode;
|
||||||
byte[] buffer = new byte[requestResult.result.Length];
|
if (requestResult.result == Stream.Null)
|
||||||
requestResult.result.ReadExactly(buffer, 0, buffer.Length);
|
return HttpStatusCode.NotFound;
|
||||||
File.WriteAllBytes(fullPath, buffer);
|
|
||||||
|
FileStream fs = new (fullPath, FileMode.Create);
|
||||||
|
requestResult.result.CopyTo(fs);
|
||||||
|
fs.Close();
|
||||||
return requestResult.statusCode;
|
return requestResult.statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user