From c8dc67d980afcd071609a3697478ade9ae439399 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 Mar 2015 00:39:29 -0400 Subject: [PATCH] sync fixes --- MediaBrowser.Server.Implementations/Sync/SyncManager.cs | 1 + .../Sync/SyncRepository.cs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index e8331e87e..19e3841d1 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -221,6 +221,7 @@ namespace MediaBrowser.Server.Implementations.Sync instance.Name = job.Name; instance.Quality = job.Quality; + instance.Profile = job.Profile; instance.UnwatchedOnly = job.UnwatchedOnly; instance.SyncNewContent = job.SyncNewContent; instance.ItemLimit = job.ItemLimit; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index f733adda9..4257fcfb9 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -441,6 +441,7 @@ namespace MediaBrowser.Server.Implementations.Sync if (!string.IsNullOrWhiteSpace(query.TargetId)) { whereClauses.Add("TargetId=@TargetId"); + cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId; } if (!string.IsNullOrWhiteSpace(query.UserId)) { @@ -453,6 +454,8 @@ namespace MediaBrowser.Server.Implementations.Sync cmd.Parameters.Add(cmd, "@SyncNewContent", DbType.Boolean).Value = query.SyncNewContent.Value; } + cmd.CommandText += " mainTable"; + var whereTextWithoutPaging = whereClauses.Count == 0 ? string.Empty : " where " + string.Join(" AND ", whereClauses.ToArray()); @@ -460,7 +463,7 @@ namespace MediaBrowser.Server.Implementations.Sync var startIndex = query.StartIndex ?? 0; if (startIndex > 0) { - whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM SyncJobs ORDER BY (Select Max(DateLastModified) from SyncJobs where TargetId=@TargetId) DESC, DateLastModified DESC LIMIT {0})", + whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM SyncJobs ORDER BY (Select Max(DateLastModified) from SyncJobs where TargetId=mainTable.TargetId) DESC, DateLastModified DESC LIMIT {0})", startIndex.ToString(_usCulture))); } @@ -469,8 +472,7 @@ namespace MediaBrowser.Server.Implementations.Sync cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray()); } - cmd.CommandText += " ORDER BY (Select Max(DateLastModified) from SyncJobs where TargetId=@TargetId) DESC, DateLastModified DESC"; - cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId; + cmd.CommandText += " ORDER BY (Select Max(DateLastModified) from SyncJobs where TargetId=mainTable.TargetId) DESC, DateLastModified DESC"; if (query.Limit.HasValue) {