Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Flow.Launcher.Core/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Updater(string gitHubRepository)

public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
{
await UpdateLock.WaitAsync();
await UpdateLock.WaitAsync().ConfigureAwait(false);
try
{
if (!silentUpdate)
Expand Down Expand Up @@ -88,9 +88,13 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
UpdateManager.RestartApp(Constant.ApplicationFileName);
}
}
catch (Exception e) when (e is HttpRequestException or WebException or SocketException || e.InnerException is TimeoutException)
catch (Exception e)
{
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
if ((e is HttpRequestException or WebException or SocketException || e.InnerException is TimeoutException))
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this, I wonder if we need to notify users when these type of errors occur?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we did? In the later part when silentupdate is false

else
Log.Exception($"|Updater.UpdateApp|Error Occurred", e);

if (!silentUpdate)
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),
api.GetTranslation("update_flowlauncher_check_connection"));
Expand Down
24 changes: 11 additions & 13 deletions Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
Expand Down Expand Up @@ -84,14 +85,14 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>

Current.MainWindow = window;
Current.MainWindow.Title = Constant.FlowLauncher;

HotKeyMapper.Initialize(_mainVM);

// happlebao todo temp fix for instance code logic
// todo temp fix for instance code logic
// load plugin before change language, because plugin language also needs be changed
InternationalizationManager.Instance.Settings = _settings;
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
// main windows needs initialized before theme change because of blur settigns
// main windows needs initialized before theme change because of blur settings
ThemeManager.Instance.Settings = _settings;
ThemeManager.Instance.ChangeTheme(_settings.Theme);

Expand Down Expand Up @@ -130,20 +131,17 @@ private void AutoStartup()
//[Conditional("RELEASE")]
private void AutoUpdates()
{
Task.Run(async () =>
_ = Task.Run(async () =>
{
if (_settings.AutoUpdates)
{
// check udpate every 5 hours
var timer = new Timer(1000 * 60 * 60 * 5);
timer.Elapsed += async (s, e) =>
{
await _updater.UpdateAppAsync(API);
};
timer.Start();

// check updates on startup
// check update every 5 hours
var timer = new PeriodicTimer(TimeSpan.FromHours(5));
await _updater.UpdateAppAsync(API);

while (await timer.WaitForNextTickAsync())
// check updates on startup
await _updater.UpdateAppAsync(API);
Comment on lines +138 to +144
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a double up of await _updater.UpdateAppAsync(API);? Doesnt it run once timer is instantiated?

}
});
}
Expand Down