diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index fe69b38cb0..ed64127c38 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -331,12 +331,11 @@ namespace MediaBrowser.Controller.LiveTv
/// The user.
/// Task.
Task AddInfoToProgramDto(List> programs, List fields, User user = null);
+
///
/// Saves the tuner host.
///
- /// The information.
- /// Task.
- Task SaveTunerHost(TunerHostInfo info);
+ Task SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
///
/// Saves the listing provider.
///
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index d042125b9b..13d5597738 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -602,7 +602,7 @@ namespace MediaBrowser.Model.Dlna
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
if (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value)
{
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index ccbcb910d3..88017aa59d 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -2475,7 +2475,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return await _libraryManager.GetNamedView(name, CollectionType.LiveTv, name, cancellationToken).ConfigureAwait(false);
}
- public async Task SaveTunerHost(TunerHostInfo info)
+ public async Task SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true)
{
info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo));
@@ -2508,7 +2508,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_config.SaveConfiguration("livetv", config);
- _taskManager.CancelIfRunningAndQueue();
+ if (dataSourceChanged)
+ {
+ _taskManager.CancelIfRunningAndQueue();
+ }
return info;
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs
index 43f48b37bf..9d5dba2823 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs
@@ -111,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
M3UUrl = info.M3UUrl,
IsEnabled = true
- }).ConfigureAwait(false);
+ }, true).ConfigureAwait(false);
}
else
{
@@ -120,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
existing.M3UUrl = info.M3UUrl;
existing.FriendlyName = info.FriendlyName;
existing.Tuners = info.Tuners;
- await _liveTvManager.SaveTunerHost(existing).ConfigureAwait(false);
+ await _liveTvManager.SaveTunerHost(existing, false).ConfigureAwait(false);
}
}
catch (OperationCanceledException)
diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
index 8b0a1d5602..64ed00ded1 100644
--- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
+++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
@@ -618,6 +618,8 @@ namespace MediaBrowser.Server.Implementations.Sync
{
var result = new Dictionary();
+ var now = DateTime.UtcNow;
+
using (var connection = CreateConnection(true).Result)
{
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("'Synced'", "'Completed','CompletedWithError'");
- Logger.Debug(cmd.CommandText);
+ //Logger.Debug(cmd.CommandText);
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
{
+ LogQueryTime("GetSyncedItemProgresses", cmd, now);
+
while (reader.Read())
{
AddStatusResult(reader, result, false);
@@ -671,6 +675,32 @@ namespace MediaBrowser.Server.Implementations.Sync
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 result, bool multipleIds)
{
if (reader.IsDBNull(0))
diff --git a/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs
index efd37fa00e..a2b5851ac0 100644
--- a/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs
+++ b/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs
@@ -144,6 +144,10 @@ namespace MediaBrowser.Server.Implementations.Sync
{
mediaSource.Id = item.Id;
mediaSource.SupportsTranscoding = false;
+ if (mediaSource.Protocol == Model.MediaInfo.MediaProtocol.File)
+ {
+ mediaSource.ETag = item.Id;
+ }
}
public Task CloseMediaSource(string liveStreamId, CancellationToken cancellationToken)
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
index 6d22aaed02..5212b8ac3e 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
@@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
Version version;
if (Version.TryParse(release.tag_name, out version))
{
- if (currentVersion >= version)
+ if (currentVersion > version)
{
newUpdateLevel = PackageVersionClass.Beta;
}
@@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
Version version;
if (Version.TryParse(release.tag_name, out version))
{
- if (currentVersion >= version)
+ if (currentVersion > version)
{
newUpdateLevel = PackageVersionClass.Dev;
}
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index c40e633749..8f153f33fe 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -163,7 +163,7 @@ namespace MediaBrowser.ServerApplication
{
_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.");
return true;