fix repeated guide refreshes

This commit is contained in:
Luke Pulverenti 2016-08-26 15:29:28 -04:00
parent 4964899fa3
commit 510fbf139c
7 changed files with 44 additions and 12 deletions

View file

@ -331,12 +331,11 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task AddInfoToProgramDto(List<Tuple<BaseItem,BaseItemDto>> programs, List<ItemFields> fields, User user = null); Task AddInfoToProgramDto(List<Tuple<BaseItem,BaseItemDto>> programs, List<ItemFields> fields, User user = null);
/// <summary> /// <summary>
/// Saves the tuner host. /// Saves the tuner host.
/// </summary> /// </summary>
/// <param name="info">The information.</param> Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
/// <returns>Task.</returns>
Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info);
/// <summary> /// <summary>
/// Saves the listing provider. /// Saves the listing provider.
/// </summary> /// </summary>

View file

@ -602,7 +602,7 @@ namespace MediaBrowser.Model.Dlna
private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream) private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
{ {
var defaultBitrate = audioStream.BitRate ?? 192000; var defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;
// Reduce the bitrate if we're downmixing // Reduce the bitrate if we're downmixing
if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value) if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value)
{ {

View file

@ -2475,7 +2475,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return await _libraryManager.GetNamedView(name, CollectionType.LiveTv, name, cancellationToken).ConfigureAwait(false); return await _libraryManager.GetNamedView(name, CollectionType.LiveTv, name, cancellationToken).ConfigureAwait(false);
} }
public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info) public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true)
{ {
info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo)); info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo));
@ -2508,7 +2508,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_config.SaveConfiguration("livetv", config); _config.SaveConfiguration("livetv", config);
_taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>(); if (dataSourceChanged)
{
_taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
}
return info; return info;
} }

View file

@ -111,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
M3UUrl = info.M3UUrl, M3UUrl = info.M3UUrl,
IsEnabled = true IsEnabled = true
}).ConfigureAwait(false); }, true).ConfigureAwait(false);
} }
else else
{ {
@ -120,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
existing.M3UUrl = info.M3UUrl; existing.M3UUrl = info.M3UUrl;
existing.FriendlyName = info.FriendlyName; existing.FriendlyName = info.FriendlyName;
existing.Tuners = info.Tuners; existing.Tuners = info.Tuners;
await _liveTvManager.SaveTunerHost(existing).ConfigureAwait(false); await _liveTvManager.SaveTunerHost(existing, false).ConfigureAwait(false);
} }
} }
catch (OperationCanceledException) catch (OperationCanceledException)

View file

@ -618,6 +618,8 @@ namespace MediaBrowser.Server.Implementations.Sync
{ {
var result = new Dictionary<string, SyncedItemProgress>(); var result = new Dictionary<string, SyncedItemProgress>();
var now = DateTime.UtcNow;
using (var connection = CreateConnection(true).Result) using (var connection = CreateConnection(true).Result)
{ {
using (var cmd = connection.CreateCommand()) using (var cmd = connection.CreateCommand())
@ -648,10 +650,12 @@ namespace MediaBrowser.Server.Implementations.Sync
.Replace("select ItemId,Status,Progress from SyncJobItems", "select ItemIds,Status,Progress from SyncJobs") .Replace("select ItemId,Status,Progress from SyncJobItems", "select ItemIds,Status,Progress from SyncJobs")
.Replace("'Synced'", "'Completed','CompletedWithError'"); .Replace("'Synced'", "'Completed','CompletedWithError'");
Logger.Debug(cmd.CommandText); //Logger.Debug(cmd.CommandText);
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
{ {
LogQueryTime("GetSyncedItemProgresses", cmd, now);
while (reader.Read()) while (reader.Read())
{ {
AddStatusResult(reader, result, false); AddStatusResult(reader, result, false);
@ -671,6 +675,32 @@ namespace MediaBrowser.Server.Implementations.Sync
return result; return result;
} }
private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate)
{
var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds;
var slowThreshold = 1000;
#if DEBUG
slowThreshold = 50;
#endif
if (elapsed >= slowThreshold)
{
Logger.Debug("{2} query time (slow): {0}ms. Query: {1}",
Convert.ToInt32(elapsed),
cmd.CommandText,
methodName);
}
else
{
//Logger.Debug("{2} query time: {0}ms. Query: {1}",
// Convert.ToInt32(elapsed),
// cmd.CommandText,
// methodName);
}
}
private void AddStatusResult(IDataReader reader, Dictionary<string, SyncedItemProgress> result, bool multipleIds) private void AddStatusResult(IDataReader reader, Dictionary<string, SyncedItemProgress> result, bool multipleIds)
{ {
if (reader.IsDBNull(0)) if (reader.IsDBNull(0))

View file

@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
Version version; Version version;
if (Version.TryParse(release.tag_name, out version)) if (Version.TryParse(release.tag_name, out version))
{ {
if (currentVersion >= version) if (currentVersion > version)
{ {
newUpdateLevel = PackageVersionClass.Beta; newUpdateLevel = PackageVersionClass.Beta;
} }
@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
Version version; Version version;
if (Version.TryParse(release.tag_name, out version)) if (Version.TryParse(release.tag_name, out version))
{ {
if (currentVersion >= version) if (currentVersion > version)
{ {
newUpdateLevel = PackageVersionClass.Dev; newUpdateLevel = PackageVersionClass.Dev;
} }

View file

@ -163,7 +163,7 @@ namespace MediaBrowser.ServerApplication
{ {
_logger.Info("Found a duplicate process. Giving it time to exit."); _logger.Info("Found a duplicate process. Giving it time to exit.");
if (!duplicate.WaitForExit(15000)) if (!duplicate.WaitForExit(20000))
{ {
_logger.Info("The duplicate process did not exit."); _logger.Info("The duplicate process did not exit.");
return true; return true;