added HasUpdateAvailable

This commit is contained in:
Luke Pulverenti 2014-01-05 01:50:48 -05:00
parent 178d216b28
commit a01ee815fb
6 changed files with 46 additions and 3 deletions

View file

@ -864,7 +864,7 @@ namespace MediaBrowser.Api.Playback
/// </summary>
/// <param name="process">The process.</param>
/// <param name="state">The state.</param>
protected void OnFfMpegProcessExited(Process process, StreamState state)
protected async void OnFfMpegProcessExited(Process process, StreamState state)
{
if (state.IsoMount != null)
{
@ -889,6 +889,18 @@ namespace MediaBrowser.Api.Playback
{
Logger.Info("FFMpeg exited with an error for {0}", outputFilePath);
}
if (!string.IsNullOrEmpty(state.LiveTvStreamId))
{
try
{
await LiveTvManager.CloseLiveStream(state.LiveTvStreamId, CancellationToken.None).ConfigureAwait(false);
}
catch (Exception ex)
{
Logger.ErrorException("Error closing live tv stream", ex);
}
}
}
/// <summary>
@ -936,6 +948,8 @@ namespace MediaBrowser.Api.Playback
{
var streamInfo = await LiveTvManager.GetRecordingStream(request.Id, cancellationToken).ConfigureAwait(false);
state.LiveTvStreamId = streamInfo.Id;
if (!string.IsNullOrEmpty(streamInfo.Path) && File.Exists(streamInfo.Path))
{
state.MediaPath = streamInfo.Path;
@ -961,6 +975,8 @@ namespace MediaBrowser.Api.Playback
var streamInfo = await LiveTvManager.GetChannelStream(request.Id, cancellationToken).ConfigureAwait(false);
state.LiveTvStreamId = streamInfo.Id;
if (!string.IsNullOrEmpty(streamInfo.Path) && File.Exists(streamInfo.Path))
{
state.MediaPath = streamInfo.Path;

View file

@ -52,5 +52,7 @@ namespace MediaBrowser.Api.Playback
public bool SendInputOverStandardInput { get; set; }
public CancellationTokenSource StandardInputCancellationTokenSource { get; set; }
public string LiveTvStreamId { get; set; }
}
}

View file

@ -227,5 +227,13 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{QueryResult{RecordingGroupDto}}.</returns>
Task<QueryResult<RecordingGroupDto>> GetRecordingGroups(RecordingGroupQuery query, CancellationToken cancellationToken);
/// <summary>
/// Closes the live stream.
/// </summary>
/// <param name="id">The identifier.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task CloseLiveStream(string id, CancellationToken cancellationToken);
}
}

View file

@ -122,6 +122,12 @@ namespace MediaBrowser.Model.System
/// <value>The wan address.</value>
public string WanAddress { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance has update available.
/// </summary>
/// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>
public bool HasUpdateAvailable { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="SystemInfo" /> class.
/// </summary>

View file

@ -945,5 +945,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
TotalRecordCount = groups.Count
};
}
public Task CloseLiveStream(string id, CancellationToken cancellationToken)
{
return ActiveService.CloseLiveStream(id, cancellationToken);
}
}
}

View file

@ -293,7 +293,7 @@ namespace MediaBrowser.ServerApplication
await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
progress.Report(100);
await ((UserManager) UserManager).Initialize().ConfigureAwait(false);
await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
SetKernelProperties();
}
@ -628,7 +628,8 @@ namespace MediaBrowser.ServerApplication
OperatingSystem = Environment.OSVersion.ToString(),
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
WanAddress = GetWanAddress()
WanAddress = GetWanAddress(),
HasUpdateAvailable = _hasUpdateAvailable
};
}
@ -699,6 +700,7 @@ namespace MediaBrowser.ServerApplication
}
}
private bool _hasUpdateAvailable;
/// <summary>
/// Checks for update.
/// </summary>
@ -712,6 +714,8 @@ namespace MediaBrowser.ServerApplication
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion,
ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
_hasUpdateAvailable = version != null;
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
}
@ -727,6 +731,8 @@ namespace MediaBrowser.ServerApplication
{
await InstallationManager.InstallPackage(package, progress, cancellationToken).ConfigureAwait(false);
_hasUpdateAvailable = false;
OnApplicationUpdated(package.version);
}