Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Dec 3, 2023
1 parent 77b7365 commit 658ea26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Handler/ShareHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ private static ProfileItem ResolveHysteria2(string result)

var query = HttpUtility.ParseQueryString(url.Query);
ResolveStdTransport(query, ref item);
item.allowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false";

return item;
}
Expand Down
35 changes: 19 additions & 16 deletions v2rayN/v2rayN/Handler/UpdateHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public class ResultEventArgs : EventArgs
{
public bool Success;
public string Msg;
public string Url;

public ResultEventArgs(bool success, string msg)
public ResultEventArgs(bool success, string msg, string url = "")
{
Success = success;
Msg = msg;
Url = url;
}
}

Expand Down Expand Up @@ -83,8 +85,9 @@ public void CheckUpdateGuiN(Config config, Action<bool, string> update, bool pre
if (args.Success)
{
_updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "v2rayN"));
_updateFunc(false, args.Msg);

url = args.Msg;
url = args.Url;
_ = askToDownload(downloadHandle, url, true);
}
else
Expand Down Expand Up @@ -135,7 +138,9 @@ public void CheckUpdateCore(ECoreType type, Config config, Action<bool, string>
if (args.Success)
{
_updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "Core"));
url = args.Msg;
_updateFunc(false, args.Msg);

url = args.Url;
_ = askToDownload(downloadHandle, url, true);
}
else
Expand Down Expand Up @@ -405,15 +410,10 @@ private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRe
try
{
var gitHubReleases = Utils.FromJson<List<GitHubRelease>>(gitHubReleaseApi);
SemanticVersion version;
if (preRelease)
{
version = new SemanticVersion(gitHubReleases!.First().TagName);
}
else
{
version = new SemanticVersion(gitHubReleases!.First(r => r.Prerelease == false).TagName);
}
var gitHubRelease = preRelease ? gitHubReleases!.First() : gitHubReleases!.First(r => r.Prerelease == false);
var version = new SemanticVersion(gitHubRelease!.TagName);
var body = gitHubRelease!.Body;

var coreInfo = LazyConfig.Instance.GetCoreInfo(type);

SemanticVersion curVersion;
Expand Down Expand Up @@ -520,7 +520,7 @@ private void responseHandler(ECoreType type, string gitHubReleaseApi, bool preRe
return;
}

AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url));
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, body, url));
}
catch (Exception ex)
{
Expand Down Expand Up @@ -603,7 +603,7 @@ private async Task UpdateGeoFile4Singbox(string geoName, Config config, bool nee
var url = string.Format(Global.singboxGeoUrl, geoName);

DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += (sender2, args) =>
downloadHandle.UpdateCompleted += async (sender2, args) =>
{
if (args.Success)
{
Expand All @@ -612,8 +612,11 @@ private async Task UpdateGeoFile4Singbox(string geoName, Config config, bool nee

try
{
if (needStop) coreHandler?.CoreStop();
Task.Delay(1000);
if (needStop)
{
coreHandler?.CoreStop();
await Task.Delay(3000);
}
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
if (File.Exists(fileName))
{
Expand Down

0 comments on commit 658ea26

Please sign in to comment.