Skip to content

Commit

Permalink
misc 修改更新逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Jun 18, 2024
1 parent fb073ba commit f832cbc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions ASFEnhance/ASFEnhance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
using ArchiSteamFarm.Plugins.Interfaces;
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Web.GitHub;
using ArchiSteamFarm.Web.GitHub.Data;
using ASFEnhance.Data.Plugin;
using System.ComponentModel;
using System.Composition;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using static ArchiSteamFarm.Storage.GlobalConfig;
using static SteamKit2.GC.Dota.Internal.CMsgDOTALeague;

namespace ASFEnhance;

Expand Down Expand Up @@ -1238,14 +1241,33 @@ public Task<bool> OnBotFriendRequest(Bot bot, ulong steamId)
/// <exception cref="NotImplementedException"></exception>
public async Task<Uri?> GetTargetReleaseURL(Version asfVersion, string asfVariant, bool asfUpdate, EUpdateChannel updateChannel, bool forced)
{
var response = await GitHubService.GetLatestRelease("chr233/ASFEnhance", true, default).ConfigureAwait(false);
if (response == null)
var releaseResponse = await GitHubService.GetLatestRelease("chr233/ASFEnhance", true, default).ConfigureAwait(false);
if (releaseResponse == null)
{
return null;
}

var releaseUrl = Update.WebRequest.FetchDownloadUrl(response);
Version newVersion = new(releaseResponse.Tag);
if (!forced && (Version >= newVersion))
{
ASFLogger.LogGenericInfo(string.Format(Langs.UpdatePluginListItemName, Name, Langs.AlreadyLatest));
return null;
}

if (releaseResponse.Assets.Count == 0)
{
ASFLogger.LogGenericWarning(Langs.NoAssetFoundInReleaseInfo);
return null;
}

ASFLogger.LogGenericInfo(string.Format(Langs.UpdatePluginListItemName, Name, Langs.CanUpdate));
ASFLogger.LogGenericInfo(string.Format(Langs.UpdatePluginListItemVersion, Version, newVersion));
if (!string.IsNullOrEmpty(releaseResponse.MarkdownBody))
{
ASFLogger.LogGenericInfo(string.Format(Langs.UpdatePluginListItemReleaseNote, releaseResponse.MarkdownBody));
}

var releaseUrl = Update.WebRequest.FetchDownloadUrl(releaseResponse);
return releaseUrl;
}
}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.1.8.1</Version>
<Version>2.1.8.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit f832cbc

Please sign in to comment.