mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Various auto-update improvements
This commit is contained in:
@@ -189,7 +189,7 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
ArchiLogger.LogGenericInfo(Strings.UpdateDownloadingNewVersion);
|
||||
ArchiLogger.LogGenericInfo(string.Format(Strings.UpdateDownloadingNewVersion, newVersion, binaryAsset.Size / 1024 / 1024));
|
||||
|
||||
byte[] result = await Program.WebBrowser.UrlGetToBytesRetry(binaryAsset.DownloadURL).ConfigureAwait(false);
|
||||
if (result == null) {
|
||||
|
||||
@@ -55,6 +55,11 @@ namespace ArchiSteamFarm.JSON {
|
||||
internal readonly string Name;
|
||||
#pragma warning restore 649
|
||||
|
||||
#pragma warning disable 649
|
||||
[JsonProperty(PropertyName = "size", Required = Required.Always)]
|
||||
internal readonly uint Size;
|
||||
#pragma warning restore 649
|
||||
|
||||
// Deserialized from JSON
|
||||
private Asset() { }
|
||||
}
|
||||
|
||||
2
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
2
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
@@ -1306,7 +1306,7 @@ namespace ArchiSteamFarm.Localization {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wyszukuje zlokalizowany ciąg podobny do ciągu Downloading new version... While waiting, consider donating if you appreciate the work being done! :).
|
||||
/// Wyszukuje zlokalizowany ciąg podobny do ciągu Downloading new version: {0} ({1} MB)... While waiting, consider donating if you appreciate the work being done! :).
|
||||
/// </summary>
|
||||
internal static string UpdateDownloadingNewVersion {
|
||||
get {
|
||||
|
||||
@@ -247,7 +247,8 @@ StackTrace:
|
||||
<value>Checking for new version...</value>
|
||||
</data>
|
||||
<data name="UpdateDownloadingNewVersion" xml:space="preserve">
|
||||
<value>Downloading new version... While waiting, consider donating if you appreciate the work being done! :)</value>
|
||||
<value>Downloading new version: {0} ({1} MB)... While waiting, consider donating if you appreciate the work being done! :)</value>
|
||||
<comment>{0} will be replaced by version string, {1} will be replaced by update size (in megabytes)</comment>
|
||||
</data>
|
||||
<data name="UpdateFinished" xml:space="preserve">
|
||||
<value>Update process finished!</value>
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace ArchiSteamFarm {
|
||||
OS.Init(GlobalConfig.Headless);
|
||||
WebBrowser.Init();
|
||||
|
||||
WebBrowser = new WebBrowser(ASF.ArchiLogger);
|
||||
WebBrowser = new WebBrowser(ASF.ArchiLogger, true);
|
||||
}
|
||||
|
||||
private static async Task<bool> InitShutdownSequence() {
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace ArchiSteamFarm {
|
||||
internal sealed class WebBrowser {
|
||||
internal const byte MaxRetries = 5; // Defines maximum number of retries, UrlRequest() does not handle retry by itself (it's app responsibility)
|
||||
|
||||
private const byte ExtendedTimeoutMultiplier = 10; // Multiplier for WebBrowsers dealing with huge data
|
||||
private const byte MaxConnections = ServicePointManager.DefaultNonPersistentConnectionLimit; // Defines maximum number of connections per ServicePoint. Be careful, as it also defines maximum number of sockets in CLOSE_WAIT state
|
||||
private const byte MaxIdleTime = 15; // In seconds, how long socket is allowed to stay in CLOSE_WAIT state after there are no connections to it
|
||||
|
||||
@@ -45,7 +46,7 @@ namespace ArchiSteamFarm {
|
||||
private readonly ArchiLogger ArchiLogger;
|
||||
private readonly HttpClient HttpClient;
|
||||
|
||||
internal WebBrowser(ArchiLogger archiLogger) {
|
||||
internal WebBrowser(ArchiLogger archiLogger, bool extendedTimeout = false) {
|
||||
ArchiLogger = archiLogger ?? throw new ArgumentNullException(nameof(archiLogger));
|
||||
|
||||
HttpClientHandler httpClientHandler = new HttpClientHandler {
|
||||
@@ -54,7 +55,7 @@ namespace ArchiSteamFarm {
|
||||
};
|
||||
|
||||
HttpClient = new HttpClient(httpClientHandler) {
|
||||
Timeout = TimeSpan.FromSeconds(Program.GlobalConfig.ConnectionTimeout)
|
||||
Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeoutMultiplier * Program.GlobalConfig.ConnectionTimeout : Program.GlobalConfig.ConnectionTimeout)
|
||||
};
|
||||
|
||||
// Most web services expect that UserAgent is set, so we declare it globally
|
||||
@@ -380,12 +381,13 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private async Task<HttpResponseMessage> UrlGetToResponse(string request, string referer = null) {
|
||||
if (!string.IsNullOrEmpty(request)) {
|
||||
return await UrlRequest(new Uri(request), HttpMethod.Get, null, referer).ConfigureAwait(false);
|
||||
if (string.IsNullOrEmpty(request)) {
|
||||
ArchiLogger.LogNullError(nameof(request));
|
||||
return null;
|
||||
}
|
||||
|
||||
ArchiLogger.LogNullError(nameof(request));
|
||||
return null;
|
||||
HttpResponseMessage result = await UrlRequest(new Uri(request), HttpMethod.Get, null, referer).ConfigureAwait(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<XmlDocument> UrlGetToXML(string request, string referer = null) {
|
||||
|
||||
Reference in New Issue
Block a user