mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
check for app updates less frequently
This commit is contained in:
parent
33eb6bca88
commit
7c0f97d56b
4 changed files with 57 additions and 22 deletions
|
@ -557,14 +557,59 @@ namespace MediaBrowser.Common.Implementations
|
||||||
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
|
||||||
public abstract bool CanSelfUpdate { get; }
|
public abstract bool CanSelfUpdate { get; }
|
||||||
|
|
||||||
|
private Tuple<CheckForUpdateResult, DateTime> _lastUpdateCheckResult;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks for update.
|
/// Checks for update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="progress">The progress.</param>
|
/// <param name="progress">The progress.</param>
|
||||||
/// <returns>Task{CheckForUpdateResult}.</returns>
|
/// <returns>Task{CheckForUpdateResult}.</returns>
|
||||||
public abstract Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken,
|
public async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken,
|
||||||
IProgress<double> progress);
|
IProgress<double> progress)
|
||||||
|
{
|
||||||
|
if (_lastUpdateCheckResult != null)
|
||||||
|
{
|
||||||
|
// Let dev users get results more often for testing purposes
|
||||||
|
var cacheLength = ConfigurationManager.CommonConfiguration.SystemUpdateLevel == PackageVersionClass.Dev
|
||||||
|
? TimeSpan.FromHours(1)
|
||||||
|
: TimeSpan.FromHours(12);
|
||||||
|
|
||||||
|
if ((DateTime.UtcNow - _lastUpdateCheckResult.Item2) < cacheLength)
|
||||||
|
{
|
||||||
|
return _lastUpdateCheckResult.Item1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await CheckForApplicationUpdateInternal(cancellationToken, progress).ConfigureAwait(false);
|
||||||
|
|
||||||
|
_lastUpdateCheckResult = new Tuple<CheckForUpdateResult, DateTime>(result, DateTime.UtcNow);
|
||||||
|
|
||||||
|
return _lastUpdateCheckResult.Item1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks for application update internal.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <param name="progress">The progress.</param>
|
||||||
|
/// <returns>Task{CheckForUpdateResult}.</returns>
|
||||||
|
private async Task<CheckForUpdateResult> CheckForApplicationUpdateInternal(CancellationToken cancellationToken,
|
||||||
|
IProgress<double> progress)
|
||||||
|
{
|
||||||
|
var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, ApplicationUpdatePackageName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||||
|
|
||||||
|
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
||||||
|
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the application update package.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name of the application update package.</value>
|
||||||
|
protected abstract string ApplicationUpdatePackageName { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the application.
|
/// Updates the application.
|
||||||
|
|
|
@ -50,11 +50,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
||||||
{
|
{
|
||||||
return new ITaskTrigger[] {
|
return new ITaskTrigger[] {
|
||||||
|
|
||||||
// 1am
|
// At startup
|
||||||
new DailyTrigger { TimeOfDay = TimeSpan.FromHours(1) },
|
new StartupTrigger (),
|
||||||
|
|
||||||
// Every three hours
|
// Every so often
|
||||||
new IntervalTrigger { Interval = TimeSpan.FromHours(3)}
|
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,11 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
return new ITaskTrigger[] {
|
return new ITaskTrigger[] {
|
||||||
|
|
||||||
// 1:30am
|
// At startup
|
||||||
new DailyTrigger { TimeOfDay = TimeSpan.FromHours(1.5) },
|
new StartupTrigger (),
|
||||||
|
|
||||||
new IntervalTrigger { Interval = TimeSpan.FromHours(3)},
|
// Every so often
|
||||||
|
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
|
||||||
new StartupTrigger()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ using MediaBrowser.Common.Implementations;
|
||||||
using MediaBrowser.Common.Implementations.IO;
|
using MediaBrowser.Common.Implementations.IO;
|
||||||
using MediaBrowser.Common.Implementations.ScheduledTasks;
|
using MediaBrowser.Common.Implementations.ScheduledTasks;
|
||||||
using MediaBrowser.Common.Implementations.Updates;
|
using MediaBrowser.Common.Implementations.Updates;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Common.MediaInfo;
|
using MediaBrowser.Common.MediaInfo;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
@ -25,11 +24,9 @@ using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.IsoMounter;
|
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using MediaBrowser.Model.System;
|
using MediaBrowser.Model.System;
|
||||||
using MediaBrowser.Model.Updates;
|
|
||||||
using MediaBrowser.Providers;
|
using MediaBrowser.Providers;
|
||||||
using MediaBrowser.Server.Implementations;
|
using MediaBrowser.Server.Implementations;
|
||||||
using MediaBrowser.Server.Implementations.BdInfo;
|
using MediaBrowser.Server.Implementations.BdInfo;
|
||||||
|
@ -53,7 +50,6 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication
|
namespace MediaBrowser.ServerApplication
|
||||||
|
@ -652,14 +648,9 @@ namespace MediaBrowser.ServerApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
protected override string ApplicationUpdatePackageName
|
||||||
{
|
{
|
||||||
var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(CancellationToken.None).ConfigureAwait(false);
|
get { return Constants.MbServerPkgName; }
|
||||||
|
|
||||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
|
||||||
|
|
||||||
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
|
||||||
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue