-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Update): Rework the way update are check to trigger a check when …
…the setting is changed. Fixes #641
- Loading branch information
Showing
6 changed files
with
119 additions
and
80 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
SoundSwitch/Framework/Updater/Job/CheckForUpdateOnceJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Job.Scheduler.Job; | ||
using Job.Scheduler.Job.Action; | ||
using Job.Scheduler.Job.Exception; | ||
using Serilog; | ||
|
||
namespace SoundSwitch.Framework.Updater.Job | ||
{ | ||
public class CheckForUpdateOnceJob : IJob | ||
{ | ||
private readonly UpdateChecker _updateChecker; | ||
|
||
public CheckForUpdateOnceJob(UpdateChecker updateChecker) | ||
{ | ||
_updateChecker = updateChecker; | ||
} | ||
|
||
public Task ExecuteAsync(CancellationToken cancellationToken) | ||
{ | ||
return _updateChecker.CheckForUpdate(cancellationToken); | ||
} | ||
|
||
public Task OnFailure(JobException exception) | ||
{ | ||
Log.Warning(exception, "Couldn't check for update"); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public IRetryAction FailRule { get; } = new RetryNTimes(3, TimeSpan.FromMinutes(1)); | ||
public TimeSpan? MaxRuntime { get; } | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
SoundSwitch/Framework/Updater/Job/CheckForUpdateRecurringJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Job.Scheduler.Job; | ||
using Job.Scheduler.Job.Action; | ||
using Job.Scheduler.Job.Exception; | ||
using Serilog; | ||
using SoundSwitch.Framework.Configuration; | ||
|
||
namespace SoundSwitch.Framework.Updater.Job | ||
{ | ||
public class CheckForUpdateRecurringJob : IRecurringJob | ||
{ | ||
private readonly UpdateChecker _updateChecker; | ||
|
||
public CheckForUpdateRecurringJob(UpdateChecker updateChecker) | ||
{ | ||
_updateChecker = updateChecker; | ||
} | ||
|
||
public Task ExecuteAsync(CancellationToken cancellationToken) | ||
{ | ||
if (AppConfigs.Configuration.UpdateMode == UpdateMode.Never) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
return _updateChecker.CheckForUpdate(cancellationToken); | ||
} | ||
|
||
public Task OnFailure(JobException exception) | ||
{ | ||
Log.Warning(exception, "Couldn't check for update"); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public IRetryAction FailRule { get; } = new AlwaysRetry(TimeSpan.FromMinutes(30)); | ||
public TimeSpan? MaxRuntime { get; } | ||
public TimeSpan Delay { get; } = TimeSpan.FromSeconds(AppConfigs.Configuration.UpdateCheckInterval); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters