mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Misc
This commit is contained in:
@@ -291,39 +291,45 @@ namespace ArchiSteamFarm {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF.ArchiLogger.LogGenericDebug("0%...");
|
ArchiLogger.LogGenericDebug("0%...");
|
||||||
|
|
||||||
using (MemoryStream ms = new MemoryStream()) {
|
using (MemoryStream ms = new MemoryStream()) {
|
||||||
using (Stream contentStream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)) {
|
try {
|
||||||
long contentLength = httpResponse.Content.Headers.ContentLength.GetValueOrDefault();
|
using (Stream contentStream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false)) {
|
||||||
byte batch = 0;
|
long contentLength = httpResponse.Content.Headers.ContentLength.GetValueOrDefault();
|
||||||
uint readThisBatch = 0;
|
byte batch = 0;
|
||||||
byte[] buffer = new byte[8192]; // This is HttpClient's buffer, using more doesn't make sense
|
uint readThisBatch = 0;
|
||||||
|
byte[] buffer = new byte[8192]; // This is HttpClient's buffer, using more doesn't make sense
|
||||||
|
|
||||||
while (contentStream.CanRead) {
|
while (contentStream.CanRead) {
|
||||||
int read = await contentStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
|
int read = await contentStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
|
||||||
if (read == 0) {
|
if (read == 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ms.WriteAsync(buffer, 0, read).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if ((contentLength == 0) || (batch >= printPercentage)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
readThisBatch += (uint) read;
|
||||||
|
|
||||||
|
if (readThisBatch < contentLength / printPercentage) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
readThisBatch = 0;
|
||||||
|
ArchiLogger.LogGenericDebug(++batch * printPercentage + "%...");
|
||||||
}
|
}
|
||||||
|
|
||||||
await ms.WriteAsync(buffer, 0, read).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if ((contentLength == 0) || (batch >= printPercentage)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
readThisBatch += (uint) read;
|
|
||||||
|
|
||||||
if (readThisBatch < contentLength / printPercentage) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
readThisBatch = 0;
|
|
||||||
ASF.ArchiLogger.LogGenericDebug(++batch * printPercentage + "%...");
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
ArchiLogger.LogGenericDebuggingException(e);
|
||||||
|
ArchiLogger.LogGenericDebug(Strings.BotReconnecting);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF.ArchiLogger.LogGenericDebug("100%");
|
ArchiLogger.LogGenericDebug("100%");
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user