<commit_before>using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Sockets;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using JetBrains.Annotations;
using Squirrel;
using Newtonsoft.Json;
using Wox.Core.Resource;
using Wox.Infrastructure;
using Wox.Infrastructure.Http;
using Wox.Infrastructure.Logger;
using System.IO;
using NLog;
using Wox.Infrastructure.UserSettings;

namespace Wox.Core
{
    public class Updater
    {
        public string GitHubRepository { get; }
        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

        public Updater(string gitHubRepository)
        {
            GitHubRepository = gitHubRepository;
        }

        public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrereleases = false)
        {
            try
            {
                using (UpdateManager updateManager = await GitHubUpdateManager(GitHubRepository, updateToPrereleases))
                {
                    UpdateInfo newUpdateInfo;
                    try
                    {
                        // UpdateApp CheckForUpdate will return value only if the app is squirrel installed
                        newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
                    }
                    catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
                    {
                        Logger.WoxError($"Check your connection and proxy settings to api.github.com.", e);
                        updateManager.Dispose();
                        return;
                    }

                    var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
                    var currentVersion = Version.Parse(Constant.Version);

                    Logger.WoxInfo($"Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");

                    if (newReleaseVersion <= currentVersion)
                    {
                        if (!silentIfLatestVersion)
                            MessageBox.Show("You already have the latest Wox version");
                        updateManager.Dispose();
                        return;
                    }

                    try
                    {
                        await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
                    }
                    catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
                    {
                        Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
                        updateManager.Dispose();
                        return;
                    }

                    await updateManager.ApplyReleases(newUpdateInfo);

                    await updateManager.CreateUninstallerRegistryEntry();

                    var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());

                    MessageBox.Show(newVersionTips);
                    Logger.WoxInfo($"Update success:{newVersionTips}");


                }
            }
            catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
            {
                Logger.WoxError($"Please check your connection and proxy settings to api.github.com.", e);
            }
            catch (Exception e)
            {
                Logger.WoxError($"cannot check update", e);
            }<commit_msg>do not report network error<commit_after>using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Sockets;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using JetBrains.Annotations;
using Squirrel;
using Newtonsoft.Json;
using Wox.Core.Resource;
using Wox.Infrastructure;
using Wox.Infrastructure.Http;
using Wox.Infrastructure.Logger;
using System.IO;
using NLog;
using Wox.Infrastructure.UserSettings;

namespace Wox.Core
{
    public class Updater
    {
        public string GitHubRepository { get; }
        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

        public Updater(string gitHubRepository)
        {
            GitHubRepository = gitHubRepository;
        }

        public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrereleases = false)
        {
            try
            {
                using (UpdateManager updateManager = await GitHubUpdateManager(GitHubRepository, updateToPrereleases))
                {
                    UpdateInfo newUpdateInfo;
                    try
                    {
                        // UpdateApp CheckForUpdate will return value only if the app is squirrel installed
                        newUpdateInfo = await updateManager.CheckForUpdate().NonNull();
                    }
                    catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
                    {
                        Logger.WoxError($"Check your connection and proxy settings to api.github.com. {e.Message}");
                        updateManager.Dispose();
                        return;
                    }

                    var newReleaseVersion = Version.Parse(newUpdateInfo.FutureReleaseEntry.Version.ToString());
                    var currentVersion = Version.Parse(Constant.Version);

                    Logger.WoxInfo($"Future Release <{newUpdateInfo.FutureReleaseEntry.Formatted()}>");

                    if (newReleaseVersion <= currentVersion)
                    {
                        if (!silentIfLatestVersion)
                            MessageBox.Show("You already have the latest Wox version");
                        updateManager.Dispose();
                        return;
                    }

                    try
                    {
                        await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply);
                    }
                    catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
                    {
                        Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com. {e.Message}");
                        updateManager.Dispose();
                        return;
                    }

                    await updateManager.ApplyReleases(newUpdateInfo);

                    await updateManager.CreateUninstallerRegistryEntry();

                    var newVersionTips = NewVersinoTips(newReleaseVersion.ToString());

                    MessageBox.Show(newVersionTips);
                    Logger.WoxInfo($"Update success:{newVersionTips}");


                }
            }
            catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException)
            {
                Logger.WoxError($"Please check your connection and proxy settings {e.Message}");
            }
            catch (Exception e)
            {
                Logger.WoxError($"cannot check update {e.Message}");
            }
{'fraction_non_alphanumeric': 0.07338565331130387, 'fraction_numerical': 0.00027536830510808204, 'mean_word_length': 1.6242774566473988, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6300658', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1595, 'n_words': 410}