diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs
index a7fd14bf0..74b37df92 100644
--- a/MediaBrowser.Api/PluginService.cs
+++ b/MediaBrowser.Api/PluginService.cs
@@ -278,9 +278,11 @@ namespace MediaBrowser.Api
///
///
///
- public async Task Post(RegisterAppstoreSale request)
+ public void Post(RegisterAppstoreSale request)
{
- await _securityManager.RegisterAppStoreSale(request.Parameters);
+ var task = _securityManager.RegisterAppStoreSale(request.Parameters);
+
+ Task.WaitAll(task);
}
///
diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs
index 19d12fe65..ead232888 100644
--- a/MediaBrowser.Api/TvShowsService.cs
+++ b/MediaBrowser.Api/TvShowsService.cs
@@ -275,38 +275,26 @@ namespace MediaBrowser.Api
var minPremiereDate = DateTime.Now.Date.AddDays(-1).ToUniversalTime();
- IEnumerable items;
+ var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
- if (string.IsNullOrWhiteSpace(request.ParentId))
+ var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
{
- items = _libraryManager.GetItems(new InternalItemsQuery(user)
- {
- IncludeItemTypes = new[] { typeof(Episode).Name },
- SortBy = new[] { "PremiereDate", "SortName" },
- SortOrder = SortOrder.Ascending,
- MinPremiereDate = minPremiereDate
+ IncludeItemTypes = new[] { typeof(Episode).Name },
+ SortBy = new[] { "PremiereDate", "AirTime", "SortName" },
+ SortOrder = SortOrder.Ascending,
+ MinPremiereDate = minPremiereDate,
+ StartIndex = request.StartIndex,
+ Limit = request.Limit
- }, user);
- }
- else
- {
- items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, request.ParentId, i => i is Episode && (i.PremiereDate ?? DateTime.MinValue) >= minPremiereDate);
- }
-
- var itemsList = _libraryManager
- .Sort(items, user, new[] { "PremiereDate", "AirTime", "SortName" }, SortOrder.Ascending)
- .Cast()
- .ToList();
-
- var pagedItems = ApplyPaging(itemsList, request.StartIndex, request.Limit);
+ }, user, parentIds);
var options = GetDtoOptions(request);
- var returnItems = _dtoService.GetBaseItemDtos(pagedItems, options, user).ToArray();
+ var returnItems = _dtoService.GetBaseItemDtos(itemsResult.Items, options, user).ToArray();
var result = new ItemsResult
{
- TotalRecordCount = itemsList.Count,
+ TotalRecordCount = itemsResult.TotalRecordCount,
Items = returnItems
};
diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
index 7cc31ad7a..1176407ce 100644
--- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
+++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
@@ -8,8 +8,10 @@ using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Model.Net;
namespace MediaBrowser.Common.Implementations.Security
{
@@ -219,10 +221,6 @@ namespace MediaBrowser.Common.Implementations.Security
{
SupporterKey = reg.key;
}
- else
- {
- throw new PaymentRequiredException();
- }
}
}
@@ -231,10 +229,15 @@ namespace MediaBrowser.Common.Implementations.Security
SaveAppStoreInfo(parameters);
throw;
}
- catch (PaymentRequiredException)
+ catch (HttpException e)
{
- SaveAppStoreInfo(parameters);
- throw;
+ _logger.ErrorException("Error registering appstore purchase {0}", e, parameters ?? "NO PARMS SENT");
+
+ if (e.StatusCode.HasValue && e.StatusCode.Value == HttpStatusCode.PaymentRequired)
+ {
+ throw new PaymentRequiredException();
+ }
+ throw new ApplicationException("Error registering store sale");
}
catch (Exception e)
{
diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs
index 14f8c1617..10372eb49 100644
--- a/MediaBrowser.Controller/Entities/AggregateFolder.cs
+++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs
@@ -128,7 +128,7 @@ namespace MediaBrowser.Controller.Entities
/// IEnumerable{BaseItem}.
protected override IEnumerable GetNonCachedChildren(IDirectoryService directoryService)
{
- return base.GetNonCachedChildren(directoryService).Concat(_virtualChildren);
+ return base.GetNonCachedChildren(directoryService);
}
///
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index fdf035e8d..f14e09616 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -639,7 +639,7 @@ namespace MediaBrowser.Controller.Entities
///
/// The tags.
public List Tags { get; set; }
-
+
///
/// Gets or sets the home page URL.
///
@@ -1898,5 +1898,24 @@ namespace MediaBrowser.Controller.Entities
DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
};
}
+
+ public virtual IEnumerable GetAncestorIds()
+ {
+ return Parents.Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id));
+ }
+
+ [IgnoreDataMember]
+ public virtual bool SupportsAncestors
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public virtual IEnumerable GetIdsForAncestorQuery()
+ {
+ return new[] { Id };
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index fcbe54d05..e08eda1ac 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -149,7 +149,15 @@ namespace MediaBrowser.Controller.Entities
await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
- await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
+ if (!EnableNewFolderQuerying())
+ {
+ await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ private static bool EnableNewFolderQuerying()
+ {
+ return ConfigurationManager.Configuration.MigrationVersion >= 1;
}
protected void AddChildrenInternal(IEnumerable children)
@@ -222,7 +230,12 @@ namespace MediaBrowser.Controller.Entities
item.SetParent(null);
- return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken);
+ if (!EnableNewFolderQuerying())
+ {
+ return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken);
+ }
+
+ return Task.FromResult(true);
}
///
@@ -471,6 +484,7 @@ namespace MediaBrowser.Controller.Entities
}
else
{
+ child.SetParent(this);
newItems.Add(child);
validChildren.Add(child);
}
@@ -478,6 +492,7 @@ namespace MediaBrowser.Controller.Entities
else
{
// Brand new item - needs to be added
+ child.SetParent(this);
newItems.Add(child);
validChildren.Add(child);
}
@@ -506,7 +521,6 @@ namespace MediaBrowser.Controller.Entities
}
else
{
- await UpdateIsOffline(item, false).ConfigureAwait(false);
actualRemovals.Add(item);
}
}
@@ -517,6 +531,9 @@ namespace MediaBrowser.Controller.Entities
foreach (var item in actualRemovals)
{
+ item.SetParent(null);
+ item.IsOffline = false;
+ await LibraryManager.DeleteItem(item, new DeleteOptions { DeleteFileLocation = false }).ConfigureAwait(false);
LibraryManager.ReportItemRemoved(item);
}
}
@@ -525,7 +542,10 @@ namespace MediaBrowser.Controller.Entities
AddChildrenInternal(newItems);
- await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
+ if (!EnableNewFolderQuerying())
+ {
+ await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
+ }
}
}
@@ -755,19 +775,16 @@ namespace MediaBrowser.Controller.Entities
/// IEnumerable{BaseItem}.
protected IEnumerable GetCachedChildren()
{
- if (ConfigurationManager.Configuration.DisableStartupScan)
+ if (EnableNewFolderQuerying())
{
- return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null);
- //return ItemRepository.GetItems(new InternalItemsQuery
- //{
- // ParentId = Id
+ return ItemRepository.GetItemList(new InternalItemsQuery
+ {
+ ParentId = Id
- //}).Items.Select(RetrieveChild).Where(i => i != null);
- }
- else
- {
- return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null);
+ }).Select(RetrieveChild).Where(i => i != null);
}
+
+ return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null);
}
private BaseItem RetrieveChild(BaseItem child)
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index 786c96d36..038a46316 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -102,7 +102,8 @@ namespace MediaBrowser.Controller.Entities
public LocationType? LocationType { get; set; }
public Guid? ParentId { get; set; }
-
+ public string[] AncestorIds { get; set; }
+
public InternalItemsQuery()
{
Tags = new string[] { };
@@ -121,6 +122,7 @@ namespace MediaBrowser.Controller.Entities
PersonIds = new string[] { };
ChannelIds = new string[] { };
ItemIds = new string[] { };
+ AncestorIds = new string[] { };
}
public InternalItemsQuery(User user)
@@ -130,6 +132,8 @@ namespace MediaBrowser.Controller.Entities
{
var policy = user.Policy;
MaxParentalRating = policy.MaxParentalRating;
+
+ User = user;
}
}
}
diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs
index 6c277da56..120a376d4 100644
--- a/MediaBrowser.Controller/Entities/Person.cs
+++ b/MediaBrowser.Controller/Entities/Person.cs
@@ -101,6 +101,15 @@ namespace MediaBrowser.Controller.Entities
return false;
}
}
+
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
}
///
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index 92ca9e970..3d18b86df 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -265,6 +265,20 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
+ public override IEnumerable GetAncestorIds()
+ {
+ var list = base.GetAncestorIds().ToList();
+
+ var seasonId = SeasonId;
+
+ if (seasonId.HasValue && !list.Contains(seasonId.Value))
+ {
+ list.Add(seasonId.Value);
+ }
+
+ return list;
+ }
+
public override IEnumerable GetDeletePaths()
{
return new[] { Path };
diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs
index 5ee49ae5a..76188ce58 100644
--- a/MediaBrowser.Controller/Entities/UserView.cs
+++ b/MediaBrowser.Controller/Entities/UserView.cs
@@ -24,6 +24,21 @@ namespace MediaBrowser.Controller.Entities
{
return true;
}
+
+ public override IEnumerable GetIdsForAncestorQuery()
+ {
+ var list = new List();
+
+ if (DisplayParentId != Guid.Empty)
+ {
+ list.Add(DisplayParentId);
+ }
+ else if (ParentId != Guid.Empty)
+ {
+ list.Add(ParentId);
+ }
+ return list;
+ }
public override Task> GetItems(InternalItemsQuery query)
{
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index 96bb6e2b6..c24cf9bce 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -549,7 +549,17 @@ namespace MediaBrowser.Controller.Library
///
/// The query.
/// The user.
+ /// The parent ids.
/// List<BaseItem>.
- IEnumerable GetItems(InternalItemsQuery query, User user);
+ IEnumerable GetItems(InternalItemsQuery query, User user, IEnumerable parentIds);
+
+ ///
+ /// Gets the items result.
+ ///
+ /// The query.
+ /// The user.
+ /// The parent ids.
+ /// QueryResult<BaseItem>.
+ QueryResult GetItemsResult(InternalItemsQuery query, User user, IEnumerable parentIds);
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
index aa1a3b9c2..55bc2269e 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
@@ -217,5 +217,14 @@ namespace MediaBrowser.Controller.LiveTv
return base.SupportsPeople;
}
}
+
+ [IgnoreDataMember]
+ public override bool SupportsAncestors
+ {
+ get
+ {
+ return false;
+ }
+ }
}
}
diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs
index 8fc0aedd3..0b1c9c3e0 100644
--- a/MediaBrowser.Controller/Persistence/IItemRepository.cs
+++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs
@@ -176,6 +176,13 @@ namespace MediaBrowser.Controller.Persistence
/// The query.
/// QueryResult<Tuple<Guid, System.String>>.
QueryResult> GetItemIdsWithPath(InternalItemsQuery query);
+
+ ///
+ /// Gets the item list.
+ ///
+ /// The query.
+ /// List<BaseItem>.
+ IEnumerable GetItemList(InternalItemsQuery query);
}
}
diff --git a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs
index a9ce5587d..ba50f2f32 100644
--- a/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs
+++ b/MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs
@@ -481,23 +481,17 @@ namespace MediaBrowser.Dlna.ContentDirectory
private QueryResult GetItemsFromPerson(Person person, User user, int? startIndex, int? limit)
{
- var itemsWithPerson = _libraryManager.GetItems(new InternalItemsQuery
+ var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
{
- Person = person.Name
+ Person = person.Name,
+ IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(ChannelVideoItem).Name },
+ SortBy = new[] { ItemSortBy.SortName },
+ Limit = limit,
+ StartIndex = startIndex
- }).Items;
+ }, user, new string[] { });
- var items = itemsWithPerson
- .Where(i => i is Movie || i is Series || i is IChannelItem)
- .Where(i => i.IsVisibleStandalone(user))
- .ToList();
-
- items = _libraryManager.Sort(items, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending)
- .Skip(startIndex ?? 0)
- .Take(limit ?? int.MaxValue)
- .ToList();
-
- var serverItems = items.Select(i => new ServerItem
+ var serverItems = itemsResult.Items.Select(i => new ServerItem
{
Item = i,
StubType = null
@@ -506,7 +500,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
return new QueryResult
{
- TotalRecordCount = serverItems.Length,
+ TotalRecordCount = itemsResult.TotalRecordCount,
Items = serverItems
};
}
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index e4c4e4762..ec024e87c 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -67,7 +67,7 @@ namespace MediaBrowser.Model.Configuration
///
/// true if [enable high quality image scaling]; otherwise, false.
public bool EnableHighQualityImageScaling { get; set; }
-
+
///
/// Gets or sets the item by name path.
///
@@ -234,12 +234,14 @@ namespace MediaBrowser.Model.Configuration
public string[] Migrations { get; set; }
+ public int MigrationVersion { get; set; }
+
///
/// Initializes a new instance of the class.
///
public ServerConfiguration()
{
- Migrations = new string[] {};
+ Migrations = new string[] { };
ImageSavingConvention = ImageSavingConvention.Compatible;
PublicPort = 8096;
@@ -583,7 +585,8 @@ namespace MediaBrowser.Model.Configuration
Limit = 0,
Type = ImageType.Thumb
}
- }
+ },
+ DisabledMetadataFetchers = new []{ "TheMovieDb" }
}
};
}
diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs
index 5c98e401f..4e742ca7a 100644
--- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs
+++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs
@@ -40,6 +40,7 @@ namespace MediaBrowser.Server.Implementations.Collections
public Folder GetCollectionsFolder(string userId)
{
return _libraryManager.RootFolder.Children.OfType()
+ .FirstOrDefault() ?? _libraryManager.GetUserRootFolder().Children.OfType()
.FirstOrDefault();
}
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index fcda802f4..8439f28f7 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -163,16 +163,11 @@ namespace MediaBrowser.Server.Implementations.Dto
if (person != null)
{
- var items = _libraryManager.GetItems(new InternalItemsQuery
+ var items = _libraryManager.GetItems(new InternalItemsQuery(user)
{
Person = byName.Name
- }).Items;
-
- if (user != null)
- {
- return items.Where(i => i.IsVisibleStandalone(user)).ToList();
- }
+ }, user, new string[] { });
return items.ToList();
}
@@ -471,8 +466,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.ChildCount = GetChildCount(folder, user);
// These are just far too slow.
- // TODO: Disable for CollectionFolder
- if (!(folder is UserRootFolder) && !(folder is UserView) && !(folder is IChannelItem))
+ if (!(folder is UserRootFolder) && !(folder is UserView) && !(folder is IChannelItem) && !(folder is ICollectionFolder))
{
SetSpecialCounts(folder, user, dto, fields, syncProgress);
}
@@ -1524,7 +1518,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
dto.ChannelId = item.ChannelId;
-
+
var channelItem = item as IChannelItem;
if (channelItem != null)
{
diff --git a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
index ec94e16db..6310b61d1 100644
--- a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
+++ b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs
@@ -83,13 +83,11 @@ namespace MediaBrowser.Server.Implementations.Intros
if (config.EnableIntrosFromMoviesInLibrary)
{
- var inputItems = _libraryManager.GetItems(new InternalItemsQuery
+ var inputItems = _libraryManager.GetItems(new InternalItemsQuery(user)
{
- IncludeItemTypes = new[] { typeof(Movie).Name },
+ IncludeItemTypes = new[] { typeof(Movie).Name }
- User = user
-
- }).Items;
+ }, user, new string[]{});
var itemsWithTrailers = inputItems
.Where(i =>
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index daa3d8ad4..522038b46 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -401,12 +401,12 @@ namespace MediaBrowser.Server.Implementations.Library
{
foreach (var path in item.GetDeletePaths().ToList())
{
- if (_fileSystem.DirectoryExists(path))
+ if (_fileSystem.DirectoryExists(path))
{
_logger.Debug("Deleting path {0}", path);
_fileSystem.DeleteDirectory(path, true);
}
- else if (_fileSystem.FileExists(path))
+ else if (_fileSystem.FileExists(path))
{
_logger.Debug("Deleting path {0}", path);
_fileSystem.DeleteFile(path);
@@ -697,7 +697,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath;
- _fileSystem.CreateDirectory(rootFolderPath);
+ _fileSystem.CreateDirectory(rootFolderPath);
var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ?? (AggregateFolder)ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath));
@@ -727,6 +727,13 @@ namespace MediaBrowser.Server.Implementations.Library
folder = dbItem;
}
+ //if (folder.ParentId != rootFolder.Id)
+ //{
+ // folder.ParentId = rootFolder.Id;
+ // var task = folder.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None);
+ // Task.WaitAll(task);
+ //}
+
rootFolder.AddVirtualChild(folder);
RegisterItem(folder);
@@ -748,7 +755,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
var userRootPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
- _fileSystem.CreateDirectory(userRootPath);
+ _fileSystem.CreateDirectory(userRootPath);
var tmpItem = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder;
@@ -1000,9 +1007,9 @@ namespace MediaBrowser.Server.Implementations.Library
private void SetPropertiesFromSongs(MusicArtist artist, IEnumerable items)
{
-
+
}
-
+
///
/// Validate and refresh the People sub-set of the IBN.
/// The items are stored in the db but not loaded into memory until actually requested by an operation.
@@ -1013,7 +1020,7 @@ namespace MediaBrowser.Server.Implementations.Library
public Task ValidatePeople(CancellationToken cancellationToken, IProgress progress)
{
// Ensure the location is available.
- _fileSystem.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
+ _fileSystem.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
return new PeopleValidator(this, _logger, ConfigurationManager, _fileSystem).ValidatePeople(cancellationToken, progress);
}
@@ -1280,9 +1287,29 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.GetItemIdsList(query);
}
- public IEnumerable GetItems(InternalItemsQuery query, User user)
+ public IEnumerable GetItems(InternalItemsQuery query, User user, IEnumerable parentIds)
{
- return GetItemIds(query).Select(GetItemById).Where(i => i.IsVisibleStandalone(user));
+ var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
+
+ query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).Select(i => i.ToString("N")).ToArray();
+
+ var items = GetItemIds(query).Select(GetItemById);
+
+ if (user != null)
+ {
+ items = items.Where(i => i.IsVisibleStandalone(user));
+ }
+
+ return items;
+ }
+
+ public QueryResult GetItemsResult(InternalItemsQuery query, User user, IEnumerable parentIds)
+ {
+ var parents = parentIds.Select(i => GetItemById(new Guid(i))).ToList();
+
+ query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).Select(i => i.ToString("N")).ToArray();
+
+ return GetItems(query);
}
///
@@ -1700,7 +1727,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (item == null ||
!string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
{
- _fileSystem.CreateDirectory(path);
+ _fileSystem.CreateDirectory(path);
item = new UserView
{
@@ -1719,8 +1746,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (!string.Equals(viewType, item.ViewType, StringComparison.OrdinalIgnoreCase))
{
- item.ViewType = viewType;
- await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
+ refresh = true;
}
if (!refresh)
@@ -1793,7 +1819,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (item == null)
{
- _fileSystem.CreateDirectory(path);
+ _fileSystem.CreateDirectory(path);
item = new UserView
{
@@ -1917,7 +1943,7 @@ namespace MediaBrowser.Server.Implementations.Library
return item;
}
-
+
public async Task GetNamedView(string name,
string parentId,
string viewType,
@@ -1946,7 +1972,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (item == null)
{
- _fileSystem.CreateDirectory(path);
+ _fileSystem.CreateDirectory(path);
item = new UserView
{
@@ -2379,7 +2405,7 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.UpdatePeople(item.Id, people);
}
- private readonly SemaphoreSlim _dynamicImageResourcePool = new SemaphoreSlim(1,1);
+ private readonly SemaphoreSlim _dynamicImageResourcePool = new SemaphoreSlim(1, 1);
public async Task ConvertImageToLocal(IHasImages item, ItemImageInfo image, int imageIndex)
{
_logger.Debug("ConvertImageToLocal item {0}", item.Id);
diff --git a/MediaBrowser.Server.Implementations/Library/MusicManager.cs b/MediaBrowser.Server.Implementations/Library/MusicManager.cs
index aee101ef4..3d2286e1f 100644
--- a/MediaBrowser.Server.Implementations/Library/MusicManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/MusicManager.cs
@@ -80,15 +80,13 @@ namespace MediaBrowser.Server.Implementations.Library
{
var genreList = genres.ToList();
- var inputItems = _libraryManager.GetItems(new InternalItemsQuery
+ var inputItems = _libraryManager.GetItems(new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(Audio).Name },
- Genres = genreList.ToArray(),
+ Genres = genreList.ToArray()
- User = user
-
- }).Items;
+ }, user, new string[] { });
var genresDictionary = genreList.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
index 108a891e0..82e0f92e6 100644
--- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
+++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
@@ -156,18 +156,18 @@ namespace MediaBrowser.Server.Implementations.Library
}
AddIfMissing(excludeItemTypes, typeof(CollectionFolder).Name);
-
+
var mediaItems = _libraryManager.GetItems(new InternalItemsQuery(user)
{
NameContains = searchTerm,
ExcludeItemTypes = excludeItemTypes.ToArray(),
IncludeItemTypes = includeItemTypes.ToArray(),
- Limit = (query.Limit.HasValue ? (int?)(query.Limit.Value * 3) : null),
+ Limit = (query.Limit.HasValue ? (int?)(query.Limit.Value * 2) : null),
- }).Items;
+ }, user, new string[] { });
// Add search hints based on item name
- hints.AddRange(mediaItems.Where(i => IncludeInSearch(i) && IsVisible(i, user)).Select(item =>
+ hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item =>
{
var index = GetIndex(item.Name, searchTerm, terms);
@@ -183,25 +183,6 @@ namespace MediaBrowser.Server.Implementations.Library
return Task.FromResult(returnValue);
}
- private bool IsVisible(BaseItem item, User user)
- {
- if (user == null)
- {
- return true;
- }
-
- if (item is IItemByName)
- {
- var dual = item as IHasDualAccess;
- if (dual == null || dual.IsAccessedByName)
- {
- return true;
- }
- }
-
- return item.IsVisibleStandalone(user);
- }
-
private bool IncludeInSearch(BaseItem item)
{
var episode = item as Episode;
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index d7c9edae3..1b8966aa0 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1357,7 +1357,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
await RefreshRecordings(cancellationToken).ConfigureAwait(false);
- var internalQuery = new InternalItemsQuery
+ var internalQuery = new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(LiveTvVideoRecording).Name, typeof(LiveTvAudioRecording).Name }
};
@@ -1367,8 +1367,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
internalQuery.ChannelIds = new[] { query.ChannelId };
}
- var queryResult = _libraryManager.GetItems(internalQuery);
- IEnumerable recordings = queryResult.Items.Cast();
+ var queryResult = _libraryManager.GetItems(internalQuery, user, new string[]{});
+ IEnumerable recordings = queryResult.Cast();
if (!string.IsNullOrEmpty(query.Id))
{
@@ -1405,12 +1405,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
.Where(i => _tvDtoService.GetInternalSeriesTimerId(i.ServiceName, i.SeriesTimerId) == guid);
}
- if (user != null)
- {
- var currentUser = user;
- recordings = recordings.Where(i => i.IsParentalAllowed(currentUser));
- }
-
recordings = recordings.OrderByDescending(i => i.StartDate);
var entityList = recordings.ToList();
@@ -1771,19 +1765,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var now = DateTime.UtcNow;
- var programs = _libraryManager.GetItems(new InternalItemsQuery
+ var programs = _libraryManager.GetItems(new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
ChannelIds = new[] { id },
MaxStartDate = now,
MinEndDate = now,
- Limit = 1
+ Limit = 1,
+ SortBy = new[] { "StartDate"}
- }).Items.Cast();
+ }, user, new string[]{}).Cast();
- var currentProgram = programs
- .OrderBy(i => i.StartDate)
- .FirstOrDefault();
+ var currentProgram = programs.FirstOrDefault();
var dto = _tvDtoService.GetChannelInfoDto(channel, new DtoOptions(), currentProgram, user);
@@ -1796,19 +1789,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var now = DateTime.UtcNow;
- var programs = _libraryManager.GetItems(new InternalItemsQuery
+ var programs = _libraryManager.GetItems(new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
ChannelIds = new[] { channel.Id.ToString("N") },
MaxStartDate = now,
MinEndDate = now,
- Limit = 1
+ Limit = 1,
+ SortBy = new[] { "StartDate" }
- }).Items.Cast();
+ }, user, new string []{}).Cast();
- var currentProgram = programs
- .OrderBy(i => i.StartDate)
- .FirstOrDefault();
+ var currentProgram = programs.FirstOrDefault();
if (currentProgram != null)
{
diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs
index 60b8c00bd..74688d9b1 100644
--- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs
@@ -24,6 +24,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;
+ public const int MigrationVersion = 1;
+
public CleanDatabaseScheduledTask(ILibraryManager libraryManager, IItemRepository itemRepo, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem)
{
_libraryManager = libraryManager;
@@ -121,6 +123,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
_config.SaveConfiguration();
}
+ if (_config.Configuration.MigrationVersion < MigrationVersion)
+ {
+ _config.Configuration.MigrationVersion = MigrationVersion;
+ _config.SaveConfiguration();
+ }
+
progress.Report(100);
}
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index 167c96185..20d890d02 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -77,7 +77,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _deleteStreamsCommand;
private IDbCommand _saveStreamCommand;
- private const int LatestSchemaVersion = 17;
+ private IDbCommand _deleteAncestorsCommand;
+ private IDbCommand _saveAncestorCommand;
+
+ private const int LatestSchemaVersion = 18;
///
/// Initializes a new instance of the class.
@@ -126,9 +129,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
string[] queries = {
- "create table if not exists TypedBaseItems (guid GUID primary key, type TEXT, data BLOB)",
+ "create table if not exists TypedBaseItems (guid GUID primary key, type TEXT, data BLOB, ParentId GUID)",
"create index if not exists idx_TypedBaseItems on TypedBaseItems(guid)",
+ "create index if not exists idx_ParentIdTypedBaseItems on TypedBaseItems(ParentId)",
+ "create table if not exists AncestorIds (ItemId GUID, AncestorId GUID, PRIMARY KEY (ItemId, AncestorId))",
+ "create index if not exists idx_AncestorIds on AncestorIds(ItemId,AncestorId)",
+
"create table if not exists ChildrenIds (ParentId GUID, ItemId GUID, PRIMARY KEY (ParentId, ItemId))",
"create index if not exists idx_ChildrenIds on ChildrenIds(ParentId,ItemId)",
@@ -205,6 +212,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(_logger, "TypedBaseItems", "Studios", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "Audio", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "ExternalServiceId", "Text");
+ _connection.AddColumn(_logger, "TypedBaseItems", "Tags", "Text");
PrepareStatements();
@@ -429,7 +437,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"LockedFields",
"Studios",
"Audio",
- "ExternalServiceId"
+ "ExternalServiceId",
+ "Tags"
};
_saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@@ -472,6 +481,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
_savePersonCommand.Parameters.Add(_savePersonCommand, "@PersonType");
_savePersonCommand.Parameters.Add(_savePersonCommand, "@SortOrder");
_savePersonCommand.Parameters.Add(_savePersonCommand, "@ListOrder");
+
+ // Ancestors
+ _deleteAncestorsCommand = _connection.CreateCommand();
+ _deleteAncestorsCommand.CommandText = "delete from AncestorIds where ItemId=@Id";
+ _deleteAncestorsCommand.Parameters.Add(_deleteAncestorsCommand, "@Id");
+
+ _saveAncestorCommand = _connection.CreateCommand();
+ _saveAncestorCommand.CommandText = "insert into AncestorIds (ItemId, AncestorId) values (@ItemId, @AncestorId)";
+ _saveAncestorCommand.Parameters.Add(_saveAncestorCommand, "@ItemId");
+ _saveAncestorCommand.Parameters.Add(_saveAncestorCommand, "@AncestorId");
// Chapters
_deleteChaptersCommand = _connection.CreateCommand();
@@ -682,9 +701,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = null;
}
+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Tags.ToArray());
+
_saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery();
+
+ if (item.SupportsAncestors)
+ {
+ UpdateAncestors(item.Id, item.GetAncestorIds().Distinct().ToList(), transaction);
+ }
}
transaction.Commit();
@@ -765,22 +791,32 @@ namespace MediaBrowser.Server.Implementations.Persistence
return null;
}
- BaseItem item;
+ BaseItem item = null;
using (var stream = reader.GetMemoryStream(1))
{
try
{
item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
-
- if (item == null)
- {
- return null;
- }
}
catch (SerializationException ex)
{
_logger.ErrorException("Error deserializing item", ex);
+ }
+
+ if (item == null)
+ {
+ try
+ {
+ item = Activator.CreateInstance(type) as BaseItem;
+ }
+ catch
+ {
+ }
+ }
+
+ if (item == null)
+ {
return null;
}
}
@@ -1328,6 +1364,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@ParentId", DbType.Guid).Value = parentId;
+ //_logger.Debug(cmd.CommandText);
+
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{
while (reader.Read())
@@ -1373,6 +1411,50 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
+ public IEnumerable GetItemList(InternalItemsQuery query)
+ {
+ if (query == null)
+ {
+ throw new ArgumentNullException("query");
+ }
+
+ CheckDisposed();
+
+ using (var cmd = _connection.CreateCommand())
+ {
+ cmd.CommandText = "select " + string.Join(",", _retriveItemColumns) + " from TypedBaseItems";
+
+ var whereClauses = GetWhereClauses(query, cmd, true);
+
+ var whereText = whereClauses.Count == 0 ?
+ string.Empty :
+ " where " + string.Join(" AND ", whereClauses.ToArray());
+
+ cmd.CommandText += whereText;
+
+ cmd.CommandText += GetOrderByText(query);
+
+ if (query.Limit.HasValue)
+ {
+ cmd.CommandText += " LIMIT " + query.Limit.Value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ //_logger.Debug(cmd.CommandText);
+
+ using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
+ {
+ while (reader.Read())
+ {
+ var item = GetItem(reader);
+ if (item != null)
+ {
+ yield return item;
+ }
+ }
+ }
+ }
+ }
+
public QueryResult GetItems(InternalItemsQuery query)
{
if (query == null)
@@ -1453,6 +1535,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
private string MapOrderByField(string name)
{
+ if (string.Equals(name, "airtime", StringComparison.OrdinalIgnoreCase))
+ {
+ // TODO
+ return "SortName";
+ }
+
return name;
}
@@ -1813,6 +1901,17 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
+ if (query.AncestorIds.Length == 1)
+ {
+ whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
+ cmd.Parameters.Add(cmd, "@AncestorId", DbType.Guid).Value = new Guid(query.AncestorIds[0]);
+ }
+ if (query.AncestorIds.Length > 1)
+ {
+ var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + i + "'").ToArray());
+ whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
+ }
+
if (addPaging)
{
if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
@@ -1847,6 +1946,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
typeof(Movie),
typeof(BoxSet),
typeof(Episode),
+ typeof(ChannelVideoItem),
typeof(Season),
typeof(Series),
typeof(Book),
@@ -1933,6 +2033,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
_deleteStreamsCommand.GetParameter(0).Value = id;
_deleteStreamsCommand.Transaction = transaction;
_deleteStreamsCommand.ExecuteNonQuery();
+
+ // Delete ancestors
+ _deleteAncestorsCommand.GetParameter(0).Value = id;
+ _deleteAncestorsCommand.Transaction = transaction;
+ _deleteAncestorsCommand.ExecuteNonQuery();
// Delete the item
_deleteItemCommand.GetParameter(0).Value = id;
@@ -2167,6 +2272,37 @@ namespace MediaBrowser.Server.Implementations.Persistence
return whereClauses;
}
+ private void UpdateAncestors(Guid itemId, List ancestorIds, IDbTransaction transaction)
+ {
+ if (itemId == Guid.Empty)
+ {
+ throw new ArgumentNullException("itemId");
+ }
+
+ if (ancestorIds == null)
+ {
+ throw new ArgumentNullException("ancestorIds");
+ }
+
+ CheckDisposed();
+
+ // First delete
+ _deleteAncestorsCommand.GetParameter(0).Value = itemId;
+ _deleteAncestorsCommand.Transaction = transaction;
+
+ _deleteAncestorsCommand.ExecuteNonQuery();
+
+ foreach (var ancestorId in ancestorIds)
+ {
+ _saveAncestorCommand.GetParameter(0).Value = itemId;
+ _saveAncestorCommand.GetParameter(1).Value = ancestorId;
+
+ _saveAncestorCommand.Transaction = transaction;
+
+ _saveAncestorCommand.ExecuteNonQuery();
+ }
+ }
+
public async Task UpdatePeople(Guid itemId, List people)
{
if (itemId == Guid.Empty)
diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs
index d9b3ed755..048e2bf8d 100644
--- a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs
@@ -264,6 +264,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
public Folder GetPlaylistsFolder(string userId)
{
return _libraryManager.RootFolder.Children.OfType()
+ .FirstOrDefault() ?? _libraryManager.GetUserRootFolder().Children.OfType()
.FirstOrDefault();
}
}
diff --git a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs
index 93ebd0a1c..d913360f0 100644
--- a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs
+++ b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs
@@ -36,22 +36,12 @@ namespace MediaBrowser.Server.Implementations.TV
? new string[] { }
: new[] { request.ParentId };
- IEnumerable items;
-
- if (parentIds.Length == 0)
+ var items = _libraryManager.GetItems(new InternalItemsQuery(user)
{
- items = _libraryManager.GetItems(new InternalItemsQuery(user)
- {
- IncludeItemTypes = new[] { typeof(Series).Name },
- SortOrder = SortOrder.Ascending
+ IncludeItemTypes = new[] { typeof(Series).Name },
+ SortOrder = SortOrder.Ascending
- }, user).Cast();
- }
- else
- {
- items = GetAllLibraryItems(user, parentIds, i => i is Series)
- .Cast();
- }
+ }, user, parentIds).Cast();
// Avoid implicitly captured closure
var episodes = GetNextUpEpisodes(request, user, items);
@@ -68,9 +58,12 @@ namespace MediaBrowser.Server.Implementations.TV
throw new ArgumentException("User not found");
}
- var items = parentsFolders
- .SelectMany(i => i.GetRecursiveChildren(user, s => s is Series))
- .Cast();
+ var items = _libraryManager.GetItems(new InternalItemsQuery(user)
+ {
+ IncludeItemTypes = new[] { typeof(Series).Name },
+ SortOrder = SortOrder.Ascending
+
+ }, user, parentsFolders.Select(i => i.Id.ToString("N"))).Cast();
// Avoid implicitly captured closure
var episodes = GetNextUpEpisodes(request, user, items);
@@ -78,27 +71,6 @@ namespace MediaBrowser.Server.Implementations.TV
return GetResult(episodes, null, request);
}
- private IEnumerable GetAllLibraryItems(User user, string[] parentIds, Func filter)
- {
- if (parentIds.Length > 0)
- {
- return parentIds.SelectMany(i =>
- {
- var folder = (Folder)_libraryManager.GetItemById(new Guid(i));
-
- return folder.GetRecursiveChildren(user, filter);
-
- });
- }
-
- if (user == null)
- {
- throw new ArgumentException("User not found");
- }
-
- return user.RootFolder.GetRecursiveChildren(user, filter);
- }
-
public IEnumerable GetNextUpEpisodes(NextUpQuery request, User user, IEnumerable series)
{
// Avoid implicitly captured closure
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 97a457a1b..694bd1b79 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -363,7 +363,7 @@ namespace MediaBrowser.Server.Startup.Common
{
var migrations = new List
{
- new Release5767(ServerConfigurationManager, TaskManager)
+ new DbMigration(ServerConfigurationManager, TaskManager)
};
foreach (var task in migrations)
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index 13b782e40..b58646a2e 100644
--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
@@ -72,7 +72,7 @@
-
+
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
new file mode 100644
index 000000000..de7cba68d
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
@@ -0,0 +1,34 @@
+using System.Threading.Tasks;
+using MediaBrowser.Common.ScheduledTasks;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Server.Implementations.Persistence;
+
+namespace MediaBrowser.Server.Startup.Common.Migrations
+{
+ public class DbMigration : IVersionMigration
+ {
+ private readonly IServerConfigurationManager _config;
+ private readonly ITaskManager _taskManager;
+
+ public DbMigration(IServerConfigurationManager config, ITaskManager taskManager)
+ {
+ _config = config;
+ _taskManager = taskManager;
+ }
+
+ public void Run()
+ {
+ if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)
+ {
+ return;
+ }
+
+ Task.Run(async () =>
+ {
+ await Task.Delay(2000).ConfigureAwait(false);
+
+ _taskManager.QueueScheduledTask();
+ });
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs b/MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs
deleted file mode 100644
index 168230b87..000000000
--- a/MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using MediaBrowser.Common.ScheduledTasks;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Server.Implementations.LiveTv;
-using MediaBrowser.Server.Implementations.Persistence;
-using MediaBrowser.Server.Implementations.ScheduledTasks;
-
-namespace MediaBrowser.Server.Startup.Common.Migrations
-{
- public class Release5767 : IVersionMigration
- {
- private readonly IServerConfigurationManager _config;
- private readonly ITaskManager _taskManager;
-
- public Release5767(IServerConfigurationManager config, ITaskManager taskManager)
- {
- _config = config;
- _taskManager = taskManager;
- }
-
- public async void Run()
- {
- var name = "5767.1";
-
- if (_config.Configuration.Migrations.Contains(name, StringComparer.OrdinalIgnoreCase))
- {
- return;
- }
-
- Task.Run(async () =>
- {
- await Task.Delay(3000).ConfigureAwait(false);
-
- _taskManager.QueueScheduledTask();
- });
-
- // Wait a few minutes before marking this as done. Make sure the server doesn't get restarted.
- await Task.Delay(300000).ConfigureAwait(false);
-
- var list = _config.Configuration.Migrations.ToList();
- list.Add(name);
- _config.Configuration.Migrations = list.ToArray();
- _config.SaveConfiguration();
- }
- }
-}