mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Refactoring
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
|
||||
namespace Wox.Update
|
||||
{
|
||||
@@ -25,28 +26,20 @@ namespace Wox.Update
|
||||
public Release CheckUpgrade(bool forceCheck = false)
|
||||
{
|
||||
if (checkedUpdate && !forceCheck) return newRelease;
|
||||
string json = HttpRequest.Get(updateURL);
|
||||
if (string.IsNullOrEmpty(json)) return null;
|
||||
|
||||
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(updateURL, HttpProxy.Instance);
|
||||
Stream s = response.GetResponseStream();
|
||||
if (s != null)
|
||||
try
|
||||
{
|
||||
StreamReader reader = new StreamReader(s, Encoding.UTF8);
|
||||
string json = reader.ReadToEnd();
|
||||
try
|
||||
{
|
||||
newRelease = JsonConvert.DeserializeObject<Release>(json);
|
||||
}
|
||||
catch
|
||||
newRelease = JsonConvert.DeserializeObject<Release>(json);
|
||||
if (!IsNewerThanCurrent(newRelease))
|
||||
{
|
||||
newRelease = null;
|
||||
}
|
||||
checkedUpdate = true;
|
||||
}
|
||||
catch{}
|
||||
|
||||
if (!IsNewerThanCurrent(newRelease))
|
||||
{
|
||||
newRelease = null;
|
||||
}
|
||||
|
||||
checkedUpdate = true;
|
||||
return newRelease;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user