sync updates

This commit is contained in:
Luke Pulverenti 2014-12-16 00:01:57 -05:00
parent 7f7d2f85e3
commit 3c48def0d7
32 changed files with 298 additions and 89 deletions

View File

@ -46,7 +46,7 @@ namespace MediaBrowser.Api.Sync
}
[Route("/Sync/Targets", "GET", Summary = "Gets a list of available sync targets.")]
public class GetSyncTarget : IReturn<List<SyncTarget>>
public class GetSyncTargets : IReturn<List<SyncTarget>>
{
[ApiMember(Name = "UserId", Description = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
public string UserId { get; set; }
@ -62,7 +62,7 @@ namespace MediaBrowser.Api.Sync
_syncManager = syncManager;
}
public object Get(GetSyncTarget request)
public object Get(GetSyncTargets request)
{
var result = _syncManager.GetSyncTargets(request.UserId);

View File

@ -140,6 +140,29 @@ namespace MediaBrowser.Controller.Entities
}
}
private UserPolicy _policy;
private readonly object _policySyncLock = new object();
[IgnoreDataMember]
public UserPolicy Policy
{
get
{
if (_policy == null)
{
lock (_policySyncLock)
{
if (_policy == null)
{
_policy = UserManager.GetUserPolicy(this);
}
}
}
return _policy;
}
set { _policy = value; }
}
/// <summary>
/// Renames the user.
/// </summary>
@ -200,7 +223,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The configuration directory path.</value>
[IgnoreDataMember]
private string ConfigurationDirectoryPath
public string ConfigurationDirectoryPath
{
get
{

View File

@ -168,9 +168,9 @@ namespace MediaBrowser.Controller.Library
/// <summary>
/// Gets the user policy.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="user">The user.</param>
/// <returns>UserPolicy.</returns>
UserPolicy GetUserPolicy(string userId);
UserPolicy GetUserPolicy(User user);
/// <summary>
/// Updates the user policy.

View File

@ -80,6 +80,9 @@
<Compile Include="..\MediaBrowser.Model\ApiClient\ConnectionMode.cs">
<Link>ApiClient\ConnectionMode.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\ApiClient\ConnectionOptions.cs">
<Link>ApiClient\ConnectionOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\ApiClient\ConnectionResult.cs">
<Link>ApiClient\ConnectionResult.cs</Link>
</Compile>
@ -1025,6 +1028,9 @@
<Compile Include="..\MediaBrowser.Model\Session\UserDataChangeInfo.cs">
<Link>Session\UserDataChangeInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncCategory.cs">
<Link>Sync\SyncCategory.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncJob.cs">
<Link>Sync\SyncJob.cs</Link>
</Compile>

View File

@ -60,6 +60,9 @@
<Compile Include="..\MediaBrowser.Model\ApiClient\ConnectionMode.cs">
<Link>ApiClient\ConnectionMode.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\ApiClient\ConnectionOptions.cs">
<Link>ApiClient\ConnectionOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\ApiClient\ConnectionState.cs">
<Link>ApiClient\ConnectionState.cs</Link>
</Compile>
@ -984,6 +987,9 @@
<Compile Include="..\MediaBrowser.Model\Session\UserDataChangeInfo.cs">
<Link>Session\UserDataChangeInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncCategory.cs">
<Link>Sync\SyncCategory.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncJob.cs">
<Link>Sync\SyncJob.cs</Link>
</Compile>

View File

@ -0,0 +1,23 @@

namespace MediaBrowser.Model.ApiClient
{
public class ConnectionOptions
{
/// <summary>
/// Gets or sets a value indicating whether [enable web socket].
/// </summary>
/// <value><c>true</c> if [enable web socket]; otherwise, <c>false</c>.</value>
public bool EnableWebSocket { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [report capabilities].
/// </summary>
/// <value><c>true</c> if [report capabilities]; otherwise, <c>false</c>.</value>
public bool ReportCapabilities { get; set; }
public ConnectionOptions()
{
EnableWebSocket = true;
ReportCapabilities = true;
}
}
}

View File

@ -77,6 +77,15 @@ namespace MediaBrowser.Model.ApiClient
/// <returns>Task&lt;ConnectionResult&gt;.</returns>
Task<ConnectionResult> Connect(ServerInfo server, CancellationToken cancellationToken);
/// <summary>
/// Connects the specified server.
/// </summary>
/// <param name="server">The server.</param>
/// <param name="options">The options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;ConnectionResult&gt;.</returns>
Task<ConnectionResult> Connect(ServerInfo server, ConnectionOptions options, CancellationToken cancellationToken);
/// <summary>
/// Connects the specified server.
/// </summary>

View File

@ -1,6 +1,7 @@
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Connect;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Users;
using System;
using System.ComponentModel;
using System.Diagnostics;
@ -60,6 +61,10 @@ namespace MediaBrowser.Model.Dto
/// <value><c>true</c> if this instance has password; otherwise, <c>false</c>.</value>
public bool HasPassword { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance has configured password.
/// </summary>
/// <value><c>true</c> if this instance has configured password; otherwise, <c>false</c>.</value>
public bool HasConfiguredPassword { get; set; }
/// <summary>
@ -80,6 +85,12 @@ namespace MediaBrowser.Model.Dto
/// <value>The configuration.</value>
public UserConfiguration Configuration { get; set; }
/// <summary>
/// Gets or sets the policy.
/// </summary>
/// <value>The policy.</value>
public UserPolicy Policy { get; set; }
/// <summary>
/// Gets or sets the primary image aspect ratio.
/// </summary>
@ -108,6 +119,7 @@ namespace MediaBrowser.Model.Dto
public UserDto()
{
Configuration = new UserConfiguration();
Policy = new UserPolicy();
}
/// <summary>

View File

@ -104,6 +104,7 @@
<Compile Include="Connect\ConnectAuthenticationResult.cs" />
<Compile Include="Connect\ConnectAuthorization.cs" />
<Compile Include="Connect\ConnectAuthorizationRequest.cs" />
<Compile Include="ApiClient\ConnectionOptions.cs" />
<Compile Include="Connect\ConnectPassword.cs" />
<Compile Include="Connect\ConnectUser.cs" />
<Compile Include="Connect\ConnectUserQuery.cs" />
@ -362,6 +363,7 @@
<Compile Include="Session\TranscodingInfo.cs" />
<Compile Include="Session\UserDataChangeInfo.cs" />
<Compile Include="Devices\ContentUploadHistory.cs" />
<Compile Include="Sync\SyncCategory.cs" />
<Compile Include="Sync\SyncHelper.cs" />
<Compile Include="Sync\SyncJob.cs" />
<Compile Include="Sync\SyncJobCreationResult.cs" />

View File

@ -0,0 +1,19 @@

namespace MediaBrowser.Model.Sync
{
public enum SyncCategory
{
/// <summary>
/// The latest
/// </summary>
Latest = 0,
/// <summary>
/// The next up
/// </summary>
NextUp = 1,
/// <summary>
/// The resume
/// </summary>
Resume = 2
}
}

View File

@ -40,6 +40,7 @@ namespace MediaBrowser.Model.Sync
if (item.IsFolder || item.IsGameGenre || item.IsMusicGenre || item.IsGenre || item.IsArtist || item.IsStudio || item.IsPerson)
{
options.Add(SyncOptions.SyncNewContent);
options.Add(SyncOptions.ItemLimit);
break;
}
}
@ -47,5 +48,17 @@ namespace MediaBrowser.Model.Sync
return options;
}
public static List<SyncOptions> GetSyncOptions(SyncCategory category)
{
List<SyncOptions> options = new List<SyncOptions>();
options.Add(SyncOptions.Quality);
options.Add(SyncOptions.UnwatchedOnly);
options.Add(SyncOptions.SyncNewContent);
options.Add(SyncOptions.ItemLimit);
return options;
}
}
}

View File

@ -21,6 +21,16 @@ namespace MediaBrowser.Model.Sync
/// <value>The quality.</value>
public SyncQuality Quality { get; set; }
/// <summary>
/// Gets or sets the category.
/// </summary>
/// <value>The category.</value>
public SyncCategory? Category { get; set; }
/// <summary>
/// Gets or sets the parent identifier.
/// </summary>
/// <value>The parent identifier.</value>
public string ParentId { get; set; }
/// <summary>
/// Gets or sets the current progress.
/// </summary>
/// <value>The current progress.</value>

View File

@ -15,6 +15,16 @@ namespace MediaBrowser.Model.Sync
/// <value>The item ids.</value>
public List<string> ItemIds { get; set; }
/// <summary>
/// Gets or sets the category.
/// </summary>
/// <value>The category.</value>
public SyncCategory? Category { get; set; }
/// <summary>
/// Gets or sets the parent identifier.
/// </summary>
/// <value>The parent identifier.</value>
public string ParentId { get; set; }
/// <summary>
/// Gets or sets the quality.
/// </summary>
/// <value>The quality.</value>

View File

@ -6,6 +6,7 @@ namespace MediaBrowser.Model.Sync
Name = 0,
Quality = 1,
UnwatchedOnly = 2,
SyncNewContent
SyncNewContent = 3,
ItemLimit = 4
}
}

View File

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MediaBrowser.Model.Users
{
public class UserPolicy
{
public bool EnableSync { get; set; }
}
}

View File

@ -13,8 +13,10 @@ using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Querying;
using MoreLinq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
@ -64,7 +66,10 @@ namespace MediaBrowser.Server.Implementations.Channels
{
CleanChannelContent(cancellationToken);
var users = _userManager.Users.Select(i => i.Id.ToString("N")).ToList();
var users = _userManager.Users
.DistinctBy(GetUserDistinctValue)
.Select(i => i.Id.ToString("N"))
.ToList();
var numComplete = 0;
@ -88,6 +93,15 @@ namespace MediaBrowser.Server.Implementations.Channels
progress.Report(100);
}
public static string GetUserDistinctValue(User user)
{
var channels = user.Configuration.BlockedChannels
.OrderBy(i => i)
.ToList();
return string.Join("|", channels.ToArray());
}
private async Task DownloadContent(string user,
CancellationToken cancellationToken,
IProgress<double> progress)
@ -201,7 +215,7 @@ namespace MediaBrowser.Server.Implementations.Channels
if (IsSizeLimitReached(path, limit.Value))
{
return;
}
}
}
var itemId = item.Id.ToString("N");

View File

@ -533,10 +533,13 @@ namespace MediaBrowser.Server.Implementations.Channels
? null
: _userManager.GetUserById(query.UserId);
var limit = query.Limit;
// See below about parental control
if (user != null)
{
query.StartIndex = null;
query.Limit = null;
}
var internalResult = await GetLatestChannelItemsInternal(query, cancellationToken).ConfigureAwait(false);
@ -554,7 +557,7 @@ namespace MediaBrowser.Server.Implementations.Channels
if (user != null)
{
items = items.Where(i => i.IsVisible(user))
.Take(10)
.Take(limit ?? 10)
.ToArray();
totalRecordCount = items.Length;

View File

@ -3,6 +3,7 @@ using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Logging;
using MoreLinq;
using System;
using System.Collections.Generic;
using System.Linq;
@ -27,6 +28,7 @@ namespace MediaBrowser.Server.Implementations.Channels
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
var users = _userManager.Users
.DistinctBy(ChannelDownloadScheduledTask.GetUserDistinctValue)
.Select(i => i.Id.ToString("N"))
.ToList();

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Events;
using System.Collections.Concurrent;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
@ -317,7 +318,8 @@ namespace MediaBrowser.Server.Implementations.Library
ConnectLinkType = user.ConnectLinkType,
ConnectUserId = user.ConnectUserId,
ConnectUserName = user.ConnectUserName,
ServerId = _appHost.SystemId
ServerId = _appHost.SystemId,
Policy = user.Policy
};
var image = user.GetImageInfo(ImageType.Primary, 0);
@ -529,6 +531,8 @@ namespace MediaBrowser.Server.Implementations.Library
_logger.ErrorException("Error deleting file {0}", ex, path);
}
DeleteUserPolicy(user);
// Force this to be lazy loaded again
Users = await LoadUsers().ConfigureAwait(false);
@ -715,7 +719,7 @@ namespace MediaBrowser.Server.Implementations.Library
var usersReset = new List<string>();
var valid = !string.IsNullOrWhiteSpace(_lastPin) &&
var valid = !string.IsNullOrWhiteSpace(_lastPin) &&
string.Equals(_lastPin, pin, StringComparison.OrdinalIgnoreCase) &&
_lastPasswordPinCreationResult != null &&
_lastPasswordPinCreationResult.ExpirationDate > DateTime.UtcNow;
@ -769,14 +773,65 @@ namespace MediaBrowser.Server.Implementations.Library
public DateTime ExpirationDate { get; set; }
}
public UserPolicy GetUserPolicy(string userId)
public UserPolicy GetUserPolicy(User user)
{
throw new NotImplementedException();
var path = GetPolifyFilePath(user);
try
{
lock (_policySyncLock)
{
return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path);
}
}
catch (Exception ex)
{
_logger.ErrorException("Error reading policy file: {0}", ex, path);
return new UserPolicy
{
EnableSync = !user.ConnectLinkType.HasValue || user.ConnectLinkType.Value != UserLinkType.Guest
};
}
}
public Task UpdateUserPolicy(string userId, UserPolicy userPolicy)
private readonly object _policySyncLock = new object();
public async Task UpdateUserPolicy(string userId, UserPolicy userPolicy)
{
throw new NotImplementedException();
var user = GetUserById(userId);
var path = GetPolifyFilePath(user);
lock (_policySyncLock)
{
_xmlSerializer.SerializeToFile(userPolicy, path);
user.Policy = userPolicy;
}
}
private void DeleteUserPolicy(User user)
{
var path = GetPolifyFilePath(user);
try
{
lock (_policySyncLock)
{
File.Delete(path);
}
}
catch (IOException)
{
}
catch (Exception ex)
{
_logger.ErrorException("Error deleting policy file", ex);
}
}
private string GetPolifyFilePath(User user)
{
return Path.Combine(user.ConfigurationDirectoryPath, "policy.xml");
}
}
}

View File

@ -1,35 +0,0 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Library;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.Library.Validators
{
public class UserViewPostScanTask : ILibraryPostScanTask
{
private readonly IUserManager _userManager;
private readonly IUserViewManager _userViewManager;
public UserViewPostScanTask(IUserManager userManager, IUserViewManager userViewManager)
{
_userManager = userManager;
_userViewManager = userViewManager;
}
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
foreach (var user in _userManager.Users)
{
foreach (var view in await _userViewManager.GetUserViews(new UserViewQuery
{
UserId = user.Id.ToString("N")
}, cancellationToken).ConfigureAwait(false))
{
await view.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
}
}
}
}

View File

@ -232,10 +232,10 @@
"HeaderFeatureAccess": "Feature Access",
"OptionAllowMediaPlayback": "Allow media playback",
"OptionAllowBrowsingLiveTv": "Allow browsing of live tv",
"OptionAllowDeleteLibraryContent": "Allow this user to delete library content",
"OptionAllowDeleteLibraryContent": "Allow deletion of library content",
"OptionAllowManageLiveTv": "Allow management of live tv recordings",
"OptionAllowRemoteControlOthers": "Allow this user to remote control other users",
"OptionAllowRemoteSharedDevices": "Allow this user to remote control shared devices",
"OptionAllowRemoteControlOthers": "Allow remote control of other users",
"OptionAllowRemoteSharedDevices": "Allow remote control of shared devices",
"OptionAllowRemoteSharedDevicesHelp": "Dlna devices are considered shared until a user begins controlling it.",
"HeaderRemoteControl": "Remote Control",
"OptionMissingTmdbId": "Missing Tmdb Id",

View File

@ -215,7 +215,6 @@
<Compile Include="Library\Validators\PeopleValidator.cs" />
<Compile Include="Library\Validators\StudiosPostScanTask.cs" />
<Compile Include="Library\Validators\StudiosValidator.cs" />
<Compile Include="Library\Validators\UserViewPostScanTask.cs" />
<Compile Include="Library\Validators\YearsPostScanTask.cs" />
<Compile Include="LiveTv\ChannelImageProvider.cs" />
<Compile Include="LiveTv\CleanDatabaseScheduledTask.cs" />

View File

@ -25,6 +25,7 @@ namespace MediaBrowser.Server.Implementations.Session
private readonly string _postUrl;
private Timer _pingTimer;
private DateTime _lastPingTime;
public HttpSessionController(IHttpClient httpClient,
IJsonSerializer json,
@ -68,10 +69,23 @@ namespace MediaBrowser.Server.Implementations.Session
try
{
await SendMessage("Ping", CancellationToken.None).ConfigureAwait(false);
_lastPingTime = DateTime.UtcNow;
}
catch
{
ReportSessionEnded();
var lastActivityDate = new[] { _lastPingTime, Session.LastActivityDate }
.Max();
var timeSinceLastPing = DateTime.UtcNow - lastActivityDate;
// We don't want to stop the session due to one single request failure
// At the same time, we don't want the timeout to be too long because it will
// be sitting in active sessions available for remote control, when it's not
if (timeSinceLastPing >= TimeSpan.FromMinutes(5))
{
ReportSessionEnded();
}
}
}
@ -90,6 +104,8 @@ namespace MediaBrowser.Server.Implementations.Session
{
if (_pingTimer != null)
{
_lastPingTime = DateTime.UtcNow;
var period = TimeSpan.FromSeconds(60);
_pingTimer.Change(period, period);
@ -101,8 +117,8 @@ namespace MediaBrowser.Server.Implementations.Session
return SendMessage(name, new Dictionary<string, string>(), cancellationToken);
}
private async Task SendMessage(string name,
Dictionary<string, string> args,
private async Task SendMessage(string name,
Dictionary<string, string> args,
CancellationToken cancellationToken)
{
var url = PostUrl + "/" + name + ToQueryString(args);

View File

@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager);
var user = _userManager.GetUserById(request.UserId);
var items = processor
.GetItemsForSync(request.ItemIds, user)
.ToList();
@ -85,7 +85,9 @@ namespace MediaBrowser.Server.Implementations.Sync
DateLastModified = DateTime.UtcNow,
SyncNewContent = request.SyncNewContent,
ItemCount = items.Count,
Quality = request.Quality
Quality = request.Quality,
Category = request.Category,
ParentId = request.ParentId
};
// It's just a static list

View File

@ -35,13 +35,13 @@ namespace MediaBrowser.Server.Implementations.Sync
public async Task Initialize()
{
var dbFile = Path.Combine(_appPaths.DataPath, "sync5.db");
var dbFile = Path.Combine(_appPaths.DataPath, "sync6.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
string[] queries = {
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, JobId TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT)",
@ -65,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_deleteJobCommand.Parameters.Add(_deleteJobCommand, "@Id");
_saveJobCommand = _connection.CreateCommand();
_saveJobCommand.CommandText = "replace into SyncJobs (Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Quality, @Status, @Progress, @UserId, @ItemIds, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_saveJobCommand.CommandText = "replace into SyncJobs (Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Quality, @Status, @Progress, @UserId, @ItemIds, @Category, @ParentId, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_saveJobCommand.Parameters.Add(_saveJobCommand, "@Id");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@TargetId");
@ -75,6 +75,8 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobCommand.Parameters.Add(_saveJobCommand, "@Progress");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@UserId");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@ItemIds");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@Category");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@ParentId");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@UnwatchedOnly");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@ItemLimit");
_saveJobCommand.Parameters.Add(_saveJobCommand, "@SyncNewContent");
@ -95,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@Progress");
}
private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobItemSelectText = "select Id, ItemId, JobId, OutputPath, Status, TargetId, DateCreated, Progress from SyncJobItems";
public SyncJob GetJob(string id)
@ -166,19 +168,29 @@ namespace MediaBrowser.Server.Implementations.Sync
if (!reader.IsDBNull(8))
{
info.UnwatchedOnly = reader.GetBoolean(8);
info.Category = (SyncCategory)Enum.Parse(typeof(SyncCategory), reader.GetString(8), true);
}
if (!reader.IsDBNull(9))
{
info.ItemLimit = reader.GetInt32(9);
info.ParentId = reader.GetString(9);
}
info.SyncNewContent = reader.GetBoolean(10);
if (!reader.IsDBNull(10))
{
info.UnwatchedOnly = reader.GetBoolean(10);
}
info.DateCreated = reader.GetDateTime(11).ToUniversalTime();
info.DateLastModified = reader.GetDateTime(12).ToUniversalTime();
info.ItemCount = reader.GetInt32(13);
if (!reader.IsDBNull(11))
{
info.ItemLimit = reader.GetInt32(11);
}
info.SyncNewContent = reader.GetBoolean(12);
info.DateCreated = reader.GetDateTime(13).ToUniversalTime();
info.DateLastModified = reader.GetDateTime(14).ToUniversalTime();
info.ItemCount = reader.GetInt32(15);
return info;
}
@ -213,6 +225,8 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobCommand.GetParameter(index++).Value = job.Progress;
_saveJobCommand.GetParameter(index++).Value = job.UserId;
_saveJobCommand.GetParameter(index++).Value = string.Join(",", job.RequestedItemIds.ToArray());
_saveJobCommand.GetParameter(index++).Value = job.Category;
_saveJobCommand.GetParameter(index++).Value = job.ParentId;
_saveJobCommand.GetParameter(index++).Value = job.UnwatchedOnly;
_saveJobCommand.GetParameter(index++).Value = job.ItemLimit;
_saveJobCommand.GetParameter(index++).Value = job.SyncNewContent;

View File

@ -341,12 +341,20 @@ namespace MediaBrowser.Server.Startup.Common
private void PerformVersionMigration()
{
new MigrateUserFolders(ApplicationPaths).Run();
new PlaylistImages(ServerConfigurationManager).Run();
new RenameXbmcOptions(ServerConfigurationManager).Run();
new RenameXmlOptions(ServerConfigurationManager).Run();
new DeprecatePlugins(ApplicationPaths).Run();
new DeleteDlnaProfiles(ApplicationPaths).Run();
var migrations = new List<IVersionMigration>
{
new MigrateUserFolders(ApplicationPaths),
new PlaylistImages(ServerConfigurationManager),
new RenameXbmcOptions(ServerConfigurationManager),
new RenameXmlOptions(ServerConfigurationManager),
new DeprecatePlugins(ApplicationPaths),
new DeleteDlnaProfiles(ApplicationPaths)
};
foreach (var task in migrations)
{
task.Run();
}
}
/// <summary>

View File

@ -3,7 +3,7 @@ using System;
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public class RenameXbmcOptions
public class RenameXbmcOptions : IVersionMigration
{
private readonly IServerConfigurationManager _config;

View File

@ -3,7 +3,7 @@ using System;
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public class RenameXmlOptions
public class RenameXmlOptions : IVersionMigration
{
private readonly IServerConfigurationManager _config;

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.519</version>
<version>3.0.520</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.519" />
<dependency id="MediaBrowser.Common" version="3.0.520" />
<dependency id="NLog" version="3.1.0.0" />
<dependency id="SimpleInjector" version="2.6.1" />
<dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.519</version>
<version>3.0.520</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Model.Signed</id>
<version>3.0.519</version>
<version>3.0.520</version>
<title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.519</version>
<version>3.0.520</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.519" />
<dependency id="MediaBrowser.Common" version="3.0.520" />
</dependencies>
</metadata>
<files>