diff --git a/MediaBrowser.Api/AlbumsService.cs b/MediaBrowser.Api/AlbumsService.cs index 46c92b7d9d..ffaa6139df 100644 --- a/MediaBrowser.Api/AlbumsService.cs +++ b/MediaBrowser.Api/AlbumsService.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Api /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// @@ -34,7 +34,7 @@ namespace MediaBrowser.Api private readonly IItemRepository _itemRepo; private readonly IDtoService _dtoService; - public AlbumsService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) + public AlbumsService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs index 14f5ba3da9..68b3fc9c84 100644 --- a/MediaBrowser.Api/GamesService.cs +++ b/MediaBrowser.Api/GamesService.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Api /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// @@ -71,7 +71,7 @@ namespace MediaBrowser.Api /// The library manager. /// The item repo. /// The dto service. - public GamesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) + public GamesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; diff --git a/MediaBrowser.Api/MoviesService.cs b/MediaBrowser.Api/MoviesService.cs index b0a4268da9..43fbe1f1b1 100644 --- a/MediaBrowser.Api/MoviesService.cs +++ b/MediaBrowser.Api/MoviesService.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Api /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// @@ -51,7 +51,7 @@ namespace MediaBrowser.Api /// The user manager. /// The user data repository. /// The library manager. - public MoviesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) + public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index 1ec58e8e30..587965b3f8 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Api /// The include in search. /// The get similarity score. /// ItemsResult. - internal static ItemsResult GetSimilarItemsResult(IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IDtoService dtoService, ILogger logger, BaseGetSimilarItemsFromItem request, Func includeInSearch, Func getSimilarityScore) + internal static ItemsResult GetSimilarItemsResult(IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataManager userDataRepository, IDtoService dtoService, ILogger logger, BaseGetSimilarItemsFromItem request, Func includeInSearch, Func getSimilarityScore) { var user = request.UserId.HasValue ? userManager.GetUserById(request.UserId.Value) : null; diff --git a/MediaBrowser.Api/TrailersService.cs b/MediaBrowser.Api/TrailersService.cs index c6336847a8..cc67c4036e 100644 --- a/MediaBrowser.Api/TrailersService.cs +++ b/MediaBrowser.Api/TrailersService.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Api /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// @@ -44,7 +44,7 @@ namespace MediaBrowser.Api /// The user manager. /// The user data repository. /// The library manager. - public TrailersService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) + public TrailersService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 382e207a72..15d6c0ae2d 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Api /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// @@ -107,7 +107,7 @@ namespace MediaBrowser.Api /// The user manager. /// The user data repository. /// The library manager. - public TvShowsService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) + public TvShowsService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) { _userManager = userManager; _userDataRepository = userDataRepository; diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 0ade4a64fa..ca626116a1 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Api.UserLibrary /// The library manager. /// The user data repository. /// The item repo. - public ArtistsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public ArtistsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 587416d835..0cb6148ccd 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -8,7 +8,6 @@ using ServiceStack.ServiceHost; using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; namespace MediaBrowser.Api.UserLibrary { @@ -27,7 +26,7 @@ namespace MediaBrowser.Api.UserLibrary /// The library manager /// protected readonly ILibraryManager LibraryManager; - protected readonly IUserDataRepository UserDataRepository; + protected readonly IUserDataManager UserDataRepository; protected readonly IItemRepository ItemRepository; protected IDtoService DtoService { get; private set; } @@ -39,7 +38,7 @@ namespace MediaBrowser.Api.UserLibrary /// The user data repository. /// The item repository. /// The dto service. - protected BaseItemsByNameService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepository, IDtoService dtoService) + protected BaseItemsByNameService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepository, IDtoService dtoService) { UserManager = userManager; LibraryManager = libraryManager; diff --git a/MediaBrowser.Api/UserLibrary/GameGenresService.cs b/MediaBrowser.Api/UserLibrary/GameGenresService.cs index 8528eea812..84ab4bf9a5 100644 --- a/MediaBrowser.Api/UserLibrary/GameGenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GameGenresService.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api.UserLibrary public class GameGenresService : BaseItemsByNameService { - public GameGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public GameGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.cs index a7561bef52..dac54e7c30 100644 --- a/MediaBrowser.Api/UserLibrary/GenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GenresService.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Api.UserLibrary /// public class GenresService : BaseItemsByNameService { - public GenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public GenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs b/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs index 609bee6684..c1d0115576 100644 --- a/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs @@ -132,7 +132,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// The user data repository /// - protected readonly IUserDataRepository UserDataRepository; + protected readonly IUserDataManager UserDataRepository; /// /// The library manager @@ -145,7 +145,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// The user data repository. /// The library manager. - public ItemByNameUserDataService(IUserDataRepository userDataRepository, ILibraryManager libraryManager, IDtoService dtoService) + public ItemByNameUserDataService(IUserDataManager userDataRepository, ILibraryManager libraryManager, IDtoService dtoService) { UserDataRepository = userDataRepository; LibraryManager = libraryManager; diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 413c683deb..b588e4a852 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -188,7 +188,7 @@ namespace MediaBrowser.Api.UserLibrary /// The _user manager /// private readonly IUserManager _userManager; - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager @@ -206,7 +206,7 @@ namespace MediaBrowser.Api.UserLibrary /// The library manager. /// The search engine. /// The user data repository. - public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILibrarySearchEngine searchEngine, IUserDataRepository userDataRepository, ILocalizationManager localization, IDtoService dtoService) + public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILibrarySearchEngine searchEngine, IUserDataManager userDataRepository, ILocalizationManager localization, IDtoService dtoService) { _userManager = userManager; _libraryManager = libraryManager; @@ -322,7 +322,7 @@ namespace MediaBrowser.Api.UserLibrary /// The user. /// The repository. /// IEnumerable{BaseItem}. - internal static IEnumerable ApplyFilter(IEnumerable items, ItemFilter filter, User user, IUserDataRepository repository) + internal static IEnumerable ApplyFilter(IEnumerable items, ItemFilter filter, User user, IUserDataManager repository) { switch (filter) { diff --git a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs index 7c131831fa..8ed280dc4d 100644 --- a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs +++ b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api.UserLibrary public class MusicGenresService : BaseItemsByNameService { - public MusicGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public MusicGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs index 7c8dc72590..57a9b01099 100644 --- a/MediaBrowser.Api/UserLibrary/PersonsService.cs +++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs @@ -59,7 +59,7 @@ namespace MediaBrowser.Api.UserLibrary /// The library manager. /// The user data repository. /// The item repo. - public PersonsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public PersonsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Api/UserLibrary/StudiosService.cs b/MediaBrowser.Api/UserLibrary/StudiosService.cs index 57046e701b..9331916790 100644 --- a/MediaBrowser.Api/UserLibrary/StudiosService.cs +++ b/MediaBrowser.Api/UserLibrary/StudiosService.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Api.UserLibrary /// public class StudiosService : BaseItemsByNameService { - public StudiosService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public StudiosService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index ead0b7fdbf..93dc411e68 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -381,7 +381,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _library manager /// @@ -399,7 +399,7 @@ namespace MediaBrowser.Api.UserLibrary /// The session manager. /// The dto service. /// jsonSerializer - public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, ISessionManager sessionManager, IDtoService dtoService) + public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, ISessionManager sessionManager, IDtoService dtoService) { _userManager = userManager; _libraryManager = libraryManager; diff --git a/MediaBrowser.Api/UserLibrary/YearsService.cs b/MediaBrowser.Api/UserLibrary/YearsService.cs index 666def277a..6d87a791cc 100644 --- a/MediaBrowser.Api/UserLibrary/YearsService.cs +++ b/MediaBrowser.Api/UserLibrary/YearsService.cs @@ -53,7 +53,7 @@ namespace MediaBrowser.Api.UserLibrary /// private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - public YearsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService) + public YearsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IDtoService dtoService) : base(userManager, libraryManager, userDataRepository, itemRepo, dtoService) { } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d13f3637a8..e05394c30b 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1333,7 +1333,7 @@ namespace MediaBrowser.Controller.Entities /// The user manager. /// Task. /// - public virtual async Task MarkPlayed(User user, DateTime? datePlayed, IUserDataRepository userManager) + public virtual async Task MarkPlayed(User user, DateTime? datePlayed, IUserDataManager userManager) { if (user == null) { @@ -1359,7 +1359,7 @@ namespace MediaBrowser.Controller.Entities /// The user manager. /// Task. /// - public virtual async Task MarkUnplayed(User user, IUserDataRepository userManager) + public virtual async Task MarkUnplayed(User user, IUserDataManager userManager) { if (user == null) { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 8d518963c8..5e6b02e08e 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1247,7 +1247,7 @@ namespace MediaBrowser.Controller.Entities /// The date played. /// The user manager. /// Task. - public override async Task MarkPlayed(User user, DateTime? datePlayed, IUserDataRepository userManager) + public override async Task MarkPlayed(User user, DateTime? datePlayed, IUserDataManager userManager) { // Sweep through recursively and update status var tasks = GetRecursiveChildren(user, true).Where(i => !i.IsFolder).Select(c => c.MarkPlayed(user, datePlayed, userManager)); @@ -1261,7 +1261,7 @@ namespace MediaBrowser.Controller.Entities /// The user. /// The user manager. /// Task. - public override async Task MarkUnplayed(User user, IUserDataRepository userManager) + public override async Task MarkUnplayed(User user, IUserDataManager userManager) { // Sweep through recursively and update status var tasks = GetRecursiveChildren(user, true).Where(i => !i.IsFolder).Select(c => c.MarkUnplayed(user, userManager)); diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs new file mode 100644 index 0000000000..d629705e9e --- /dev/null +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -0,0 +1,28 @@ +using MediaBrowser.Controller.Entities; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Library +{ + public interface IUserDataManager + { + /// + /// Saves the user data. + /// + /// The user id. + /// The key. + /// The user data. + /// The cancellation token. + /// Task. + Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); + + /// + /// Gets the user data. + /// + /// The user id. + /// The key. + /// Task{UserItemData}. + UserItemData GetUserData(Guid userId, string key); + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 3b94ea35c1..760ff382ca 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -97,6 +97,7 @@ + diff --git a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs index 282952dba2..b0ce7bf7c6 100644 --- a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs @@ -24,8 +24,7 @@ namespace MediaBrowser.Controller.Persistence /// The user data. /// The cancellation token. /// Task. - Task SaveUserData(Guid userId, string key, UserItemData userData, - CancellationToken cancellationToken); + Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); /// /// Gets the user data. diff --git a/MediaBrowser.Controller/Sorting/IUserBaseItemComparer.cs b/MediaBrowser.Controller/Sorting/IUserBaseItemComparer.cs index d464a64a07..915d4854bb 100644 --- a/MediaBrowser.Controller/Sorting/IUserBaseItemComparer.cs +++ b/MediaBrowser.Controller/Sorting/IUserBaseItemComparer.cs @@ -1,6 +1,5 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.Persistence; namespace MediaBrowser.Controller.Sorting { @@ -25,6 +24,6 @@ namespace MediaBrowser.Controller.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - IUserDataRepository UserDataRepository { get; set; } + IUserDataManager UserDataRepository { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index ee69bbc971..00808ad330 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -27,12 +27,12 @@ namespace MediaBrowser.Server.Implementations.Dto private readonly ILogger _logger; private readonly ILibraryManager _libraryManager; private readonly IUserManager _userManager; - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; private readonly IItemRepository _itemRepo; private readonly IImageProcessor _imageProcessor; - - public DtoService(ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor) + + public DtoService(ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor) { _logger = logger; _libraryManager = libraryManager; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index de096e3b3b..d54bb94de4 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -113,7 +113,7 @@ namespace MediaBrowser.Server.Implementations.Library /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// Gets or sets the configuration manager. @@ -172,7 +172,7 @@ namespace MediaBrowser.Server.Implementations.Library /// The user manager. /// The configuration manager. /// The user data repository. - public LibraryManager(ILogger logger, ITaskManager taskManager, IUserManager userManager, IServerConfigurationManager configurationManager, IUserDataRepository userDataRepository, Func directoryWatchersFactory) + public LibraryManager(ILogger logger, ITaskManager taskManager, IUserManager userManager, IServerConfigurationManager configurationManager, IUserDataManager userDataRepository, Func directoryWatchersFactory) { _logger = logger; _taskManager = taskManager; diff --git a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs new file mode 100644 index 0000000000..f382df0f0a --- /dev/null +++ b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs @@ -0,0 +1,45 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Persistence; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Server.Implementations.Library +{ + /// + /// Class UserDataManager + /// + public class UserDataManager : IUserDataManager + { + /// + /// Gets or sets the repository. + /// + /// The repository. + public IUserDataRepository Repository { get; set; } + + /// + /// Saves the user data. + /// + /// The user id. + /// The key. + /// The user data. + /// The cancellation token. + /// Task. + public Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) + { + return Repository.SaveUserData(userId, key, userData, cancellationToken); + } + + /// + /// Gets the user data. + /// + /// The user id. + /// The key. + /// Task{UserItemData}. + public UserItemData GetUserData(Guid userId, string key) + { + return Repository.GetUserData(userId, key); + } + } +} diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 79ad8ada7c..b0f7553eab 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -142,6 +142,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 346c496ce3..1659901c6c 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.Session /// /// The _user data repository /// - private readonly IUserDataRepository _userDataRepository; + private readonly IUserDataManager _userDataRepository; /// /// The _user repository @@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.Session /// The configuration manager. /// The logger. /// The user repository. - public SessionManager(IUserDataRepository userDataRepository, IServerConfigurationManager configurationManager, ILogger logger, IUserRepository userRepository) + public SessionManager(IUserDataManager userDataRepository, IServerConfigurationManager configurationManager, ILogger logger, IUserRepository userRepository) { _userDataRepository = userDataRepository; _configurationManager = configurationManager; diff --git a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs index 62f0e0ae0e..8e24bc52d6 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/DatePlayedComparer.cs b/MediaBrowser.Server.Implementations/Sorting/DatePlayedComparer.cs index 2abd4d0f20..7605a7a50d 100644 --- a/MediaBrowser.Server.Implementations/Sorting/DatePlayedComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/DatePlayedComparer.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs index e4eaad2aa2..7731e59d2b 100644 --- a/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/IsUnplayedComparer.cs b/MediaBrowser.Server.Implementations/Sorting/IsUnplayedComparer.cs index 5323734c08..596b344def 100644 --- a/MediaBrowser.Server.Implementations/Sorting/IsUnplayedComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/IsUnplayedComparer.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Gets or sets the user manager. @@ -113,7 +113,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Gets or sets the user manager. diff --git a/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs index 9444a33219..51f39a02f2 100644 --- a/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs index 3f578d33a7..889658459c 100644 --- a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs index d4c22e6e02..0d10c459f1 100644 --- a/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/PlayCountComparer.cs @@ -53,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Gets or sets the user manager. diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs index f8c8c4bce5..13d2932cbc 100644 --- a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs index ac05471029..b12e1322a0 100644 --- a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs index 2af2cdf9c2..b6f67410a0 100644 --- a/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// Gets or sets the user data repository. /// /// The user data repository. - public IUserDataRepository UserDataRepository { get; set; } + public IUserDataManager UserDataRepository { get; set; } /// /// Compares the specified x. diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index b54ca6e347..a61abe4741 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -160,7 +160,7 @@ namespace MediaBrowser.ServerApplication /// Gets or sets the user data repository. /// /// The user data repository. - private IUserDataRepository UserDataRepository { get; set; } + private IUserDataManager UserDataManager { get; set; } private IUserRepository UserRepository { get; set; } internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; } private IItemRepository ItemRepository { get; set; } @@ -238,8 +238,8 @@ namespace MediaBrowser.ServerApplication var mediaEncoderTask = RegisterMediaEncoder(); - UserDataRepository = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager); - RegisterSingleInstance(UserDataRepository); + UserDataManager = new UserDataManager(); + RegisterSingleInstance(UserDataManager); UserRepository = await GetUserRepository().ConfigureAwait(false); RegisterSingleInstance(UserRepository); @@ -253,7 +253,7 @@ namespace MediaBrowser.ServerApplication UserManager = new UserManager(Logger, ServerConfigurationManager, UserRepository); RegisterSingleInstance(UserManager); - LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataRepository, () => DirectoryWatchers); + LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => DirectoryWatchers); RegisterSingleInstance(LibraryManager); DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager); @@ -264,7 +264,7 @@ namespace MediaBrowser.ServerApplication RegisterSingleInstance(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager)); - SessionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository); + SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository); RegisterSingleInstance(SessionManager); HttpServer = await _httpServerCreationTask.ConfigureAwait(false); @@ -279,7 +279,7 @@ namespace MediaBrowser.ServerApplication ImageProcessor = new ImageProcessor(Logger, ServerConfigurationManager.ApplicationPaths); RegisterSingleInstance(ImageProcessor); - DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataRepository, ItemRepository, ImageProcessor); + DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor); RegisterSingleInstance(DtoService); LiveTvManager = new LiveTvManager(); @@ -372,9 +372,13 @@ namespace MediaBrowser.ServerApplication /// Configures the user data repositories. /// /// Task. - private Task ConfigureUserDataRepositories() + private async Task ConfigureUserDataRepositories() { - return UserDataRepository.Initialize(); + var repo = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager); + + await repo.Initialize().ConfigureAwait(false); + + ((UserDataManager) UserDataManager).Repository = repo; } /// diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 9653ae70e2..9308e6fb56 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.213 + 3.0.214 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 556744ff10..4f2a88bc27 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.213 + 3.0.214 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 761244fe85..f34d066b80 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.213 + 3.0.214 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +