The Free Software Media System - Server Backend & API
make channel access opt-in rather than opt out
Luke Pulverentid8d5dd487326
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.csindex 0eb92d5a7e..a9b43090a2 100644--- a/MediaBrowser.Api/ApiEntryPoint.cs+++ b/MediaBrowser.Api/ApiEntryPoint.cs@@ -1,5 +1,6 @@using MediaBrowser.Api.Playback;using MediaBrowser.Common.Configuration;+using MediaBrowser.Common.IO;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Plugins;using MediaBrowser.Controller.Session;@@ -39,6 +40,7 @@ namespace MediaBrowser.Apiprivate readonly IServerConfigurationManager _config;private readonly ISessionManager _sessionManager;+ private readonly IFileSystem _fileSystem;public readonly SemaphoreSlim TranscodingStartLock = new SemaphoreSlim(1, 1);@@ -48,11 +50,12 @@ namespace MediaBrowser.Api/// <param name="logger">The logger.</param>/// <param name="sessionManager">The session manager.</param>/// <param name="config">The configuration.</param>- public ApiEntryPoint(ILogger logger, ISessionManager sessionManager, IServerConfigurationManager config)+ public ApiEntryPoint(ILogger logger, ISessionManager sessionManager, IServerConfigurationManager config, IFileSystem fileSystem){Logger = logger;_sessionManager = sessionManager;_config = config;+ _fileSystem = fileSystem;Instance = this;}@@ -91,7 +94,7 @@ namespace MediaBrowser.Apiforeach (var file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories).ToList()){- File.Delete(file);+ _fileSystem.DeleteFile(file);}}@@ -462,7 +465,7 @@ namespace MediaBrowser.Api/// <param name="outputFilePath">The output file path.</param>private void DeleteProgressivePartialStreamFiles(string outputFilePath){- File.Delete(outputFilePath);+ _fileSystem.DeleteFile(outputFilePath);}/// <summary>@@ -479,13 +482,13 @@ namespace MediaBrowser.Api.ToList();Exception e = null;-+foreach (var file in filesToDelete){try{Logger.Info("Deleting HLS file {0}", file);- File.Delete(file);+ _fileSystem.DeleteFile(file);}catch (DirectoryNotFoundException){diff --git a/MediaBrowser.Api/ConnectService.cs b/MediaBrowser.Api/ConnectService.csindex 102e2d45ea..a5ddcb6f1d 100644--- a/MediaBrowser.Api/ConnectService.cs+++ b/MediaBrowser.Api/ConnectService.cs@@ -42,8 +42,8 @@ namespace MediaBrowser.Api[ApiMember(Name = "ExcludeLibraries", Description = "ExcludeLibraries", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]public string ExcludedLibraries { get; set; }- [ApiMember(Name = "ExcludedChannels", Description = "ExcludedChannels", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]- public string ExcludedChannels { get; set; }+ [ApiMember(Name = "EnabledChannels", Description = "EnabledChannels", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]+ public string EnabledChannels { get; set; }[ApiMember(Name = "EnableLiveTv", Description = "EnableLiveTv", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]public bool EnableLiveTv { get; set; }@@ -96,7 +96,7 @@ namespace MediaBrowser.Api.Where(i => !string.IsNullOrWhiteSpace(i)).ToArray();- var excludedChannels = (request.ExcludedChannels ?? string.Empty)+ var enabledChannels = (request.EnabledChannels ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray();@@ -106,7 +106,7 @@ namespace MediaBrowser.ApiConnectUserName = request.ConnectUsername,SendingUserId = request.SendingUserId,ExcludedLibraries = excludeLibraries,- ExcludedChannels = excludedChannels,+ EnabledChannels = enabledChannels,EnableLiveTv = request.EnableLiveTv});}diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.csindex e21dc4a73b..0ee28d6fef 100644--- a/MediaBrowser.Api/Library/LibraryHelpers.cs+++ b/MediaBrowser.Api/Library/LibraryHelpers.cs@@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Libraryif (!string.IsNullOrEmpty(shortcut)){- File.Delete(shortcut);+ fileSystem.DeleteFile(shortcut);}}diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.csindex ee80d4b734..23f4e4e5c1 100644--- a/MediaBrowser.Api/Library/LibraryStructureService.cs+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs@@ -348,7 +348,7 @@ namespace MediaBrowser.Api.Librarytry{- Directory.Delete(path, true);+ _fileSystem.DeleteDirectory(path, true);// Need to add a delay here or directory watchers may still pick up the changesvar delayTask = Task.Delay(1000);diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.csindex 86866bdf5e..53229f0310 100644--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs@@ -210,10 +210,10 @@ namespace MediaBrowser.Api.Playback.Hls{return;}-+try{- File.Delete(file.FullName);+ FileSystem.DeleteFile(file.FullName);}catch (IOException ex){diff --git a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs b/MediaBrowser.Api/Playback/Hls/MpegDashService.csindex 87e2eedcf5..514597c3e1 100644--- a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs+++ b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs@@ -489,7 +489,7 @@ namespace MediaBrowser.Api.Playback.Hls{try{- File.Delete(file.FullName);+ FileSystem.DeleteFile(file.FullName);}catch (IOException ex){diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.csindex 59b8e85c22..e5fe69b622 100644--- a/MediaBrowser.Api/Session/SessionsService.cs+++ b/MediaBrowser.Api/Session/SessionsService.cs@@ -245,6 +245,11 @@ namespace MediaBrowser.Api.Session[ApiMember(Name = "SupportsUniqueIdentifier", Description = "Determines whether the device supports a unique identifier.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]public bool SupportsUniqueIdentifier { get; set; }++ public PostCapabilities()+ {+ SupportsUniqueIdentifier = true;+ }}[Route("/Sessions/Capabilities/Full", "POST", Summary = "Updates capabilities for a device")]diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.csindex 4443b2a2bc..97401bbf84 100644--- a/MediaBrowser.Api/StartupWizardService.cs+++ b/MediaBrowser.Api/StartupWizardService.cs@@ -62,6 +62,8 @@ namespace MediaBrowser.Api{_config.Configuration.IsStartupWizardCompleted = true;_config.Configuration.EnableLocalizedGuids = true;+ _config.Configuration.StoreArtistsInMetadata = true;+ _config.Configuration.EnableLibraryMetadataSubFolder = true;_config.SaveConfiguration();}diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.csindex c98a6bd6cc..0f89bd1a6f 100644--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs@@ -475,7 +475,7 @@ namespace MediaBrowser.Common.ImplementationsSecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager);RegisterSingleInstance(SecurityManager);- InstallationManager = new InstallationManager(Logger, this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager);+ InstallationManager = new InstallationManager(Logger, this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager);RegisterSingleInstance(InstallationManager);ZipClient = new ZipClient();diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.csindex 1f82c5eb0c..b925649fce 100644--- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs+++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs@@ -690,7 +690,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager{try{- File.Delete(file);+ _fileSystem.DeleteFile(file);}catch (IOException){diff --git a/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs b/MediaBrowser.Common.Implementations/IO/CommonFileSystem.csindex 68df0e52ac..c54b053fda 100644--- a/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs+++ b/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs@@ -270,8 +270,8 @@ namespace MediaBrowser.Common.Implementations.IOFile.Copy(temp1, file2, true);File.Copy(temp2, file1, true);- File.Delete(temp1);- File.Delete(temp2);+ DeleteFile(temp1);+ DeleteFile(temp2);}/// <summary>@@ -409,5 +409,25 @@ namespace MediaBrowser.Common.Implementations.IO//return Path.IsPathRooted(path);}++ public void DeleteFile(string path, bool sendToRecycleBin)+ {+ File.Delete(path);+ }++ public void DeleteDirectory(string path, bool recursive, bool sendToRecycleBin)+ {+ Directory.Delete(path, recursive);+ }++ public void DeleteFile(string path)+ {+ DeleteFile(path, false);+ }++ public void DeleteDirectory(string path, bool recursive)+ {+ DeleteDirectory(path, recursive, false);+ }}}diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.csindex fcb7b159b8..779f992d32 100644--- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs@@ -125,7 +125,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks{try{- File.Delete(path);+ _fileSystem.DeleteFile(path);}catch (IOException ex){diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.csindex 3b0c02dc6b..6b9bcbfc1a 100644--- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs@@ -76,7 +76,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.TaskscancellationToken.ThrowIfCancellationRequested();- File.Delete(file.FullName);+ _fileSystem.DeleteFile(file.FullName);index++;}diff --git a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs b/MediaBrowser.Common.Implementations/Updates/InstallationManager.csindex 47215aacf1..264e63b47f 100644--- a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs+++ b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs@@ -1,6 +1,7 @@using MediaBrowser.Common.Configuration;using MediaBrowser.Common.Events;using MediaBrowser.Common.Implementations.Security;+using MediaBrowser.Common.IO;using MediaBrowser.Common.Net;using MediaBrowser.Common.Plugins;using MediaBrowser.Common.Progress;@@ -106,6 +107,7 @@ namespace MediaBrowser.Common.Implementations.Updatesprivate readonly IJsonSerializer _jsonSerializer;private readonly ISecurityManager _securityManager;private readonly IConfigurationManager _config;+ private readonly IFileSystem _fileSystem;/// <summary>/// Gets the application host.@@ -113,7 +115,7 @@ namespace MediaBrowser.Common.Implementations.Updates/// <value>The application host.</value>private readonly IApplicationHost _applicationHost;- public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config)+ public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem){if (logger == null){@@ -129,6 +131,7 @@ namespace MediaBrowser.Common.Implementations.Updates_jsonSerializer = jsonSerializer;_securityManager = securityManager;_config = config;+ _fileSystem = fileSystem;_logger = logger;}@@ -570,7 +573,7 @@ namespace MediaBrowser.Common.Implementations.Updatestry{- File.Delete(tempFile);+ _fileSystem.DeleteFile(tempFile);}catch (IOException e){@@ -591,7 +594,7 @@ namespace MediaBrowser.Common.Implementations.Updates// Remove it the quick way for now_applicationHost.RemovePlugin(plugin);- File.Delete(plugin.AssemblyFilePath);+ _fileSystem.DeleteFile(plugin.AssemblyFilePath);OnPluginUninstalled(plugin);diff --git a/MediaBrowser.Common/IO/IFileSystem.cs b/MediaBrowser.Common/IO/IFileSystem.csindex 3bcec98ce6..5ce84f4360 100644--- a/MediaBrowser.Common/IO/IFileSystem.cs+++ b/MediaBrowser.Common/IO/IFileSystem.cs@@ -133,5 +133,33 @@ namespace MediaBrowser.Common.IO/// <param name="path">The path.</param>/// <returns><c>true</c> if [is path file] [the specified path]; otherwise, <c>false</c>.</returns>bool IsPathFile(string path);++ /// <summary>+ /// Deletes the file.+ /// </summary>+ /// <param name="path">The path.</param>+ /// <param name="sendToRecycleBin">if set to <c>true</c> [send to recycle bin].</param>+ void DeleteFile(string path, bool sendToRecycleBin);++ /// <summary>+ /// Deletes the directory.+ /// </summary>+ /// <param name="path">The path.</param>+ /// <param name="recursive">if set to <c>true</c> [recursive].</param>+ /// <param name="sendToRecycleBin">if set to <c>true</c> [send to recycle bin].</param>+ void DeleteDirectory(string path, bool recursive, bool sendToRecycleBin);++ /// <summary>+ /// Deletes the file.+ /// </summary>+ /// <param name="path">The path.</param>+ void DeleteFile(string path);++ /// <summary>+ /// Deletes the directory.+ /// </summary>+ /// <param name="path">The path.</param>+ /// <param name="recursive">if set to <c>true</c> [recursive].</param>+ void DeleteDirectory(string path, bool recursive);}}diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.csindex 5a9fc33227..6ee6fe0062 100644--- a/MediaBrowser.Controller/Channels/Channel.cs+++ b/MediaBrowser.Controller/Channels/Channel.cs@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Channelspublic override bool IsVisible(User user){- if (user.Policy.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))+ if (!user.Policy.EnableAllChannels && !user.Policy.EnabledChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)){return false;}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex ee562d8b49..6a30df7fe8 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -379,7 +379,14 @@ namespace MediaBrowser.Controller.Entitiespublic string GetInternalMetadataPath(){- return GetInternalMetadataPath(ConfigurationManager.ApplicationPaths.InternalMetadataPath);+ var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath;++ if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder)+ {+ basePath = System.IO.Path.Combine(basePath, "library");+ }++ return GetInternalMetadataPath(basePath);}protected virtual string GetInternalMetadataPath(string basePath)@@ -1458,7 +1465,7 @@ namespace MediaBrowser.Controller.EntitiescurrentFile.Attributes &= ~FileAttributes.Hidden;}- currentFile.Delete();+ FileSystem.DeleteFile(currentFile.FullName);}return UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None);diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.csindex 626afcfdfe..869c30ba88 100644--- a/MediaBrowser.Controller/Entities/User.cs+++ b/MediaBrowser.Controller/Entities/User.cs@@ -177,7 +177,7 @@ namespace MediaBrowser.Controller.Entities// Exceptions will be thrown if these paths already existif (Directory.Exists(newConfigDirectory)){- Directory.Delete(newConfigDirectory, true);+ FileSystem.DeleteDirectory(newConfigDirectory, true);}if (Directory.Exists(oldConfigurationDirectory))diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.csindex e3438c3d25..c07934d0b1 100644--- a/MediaBrowser.Controller/IServerApplicationPaths.cs+++ b/MediaBrowser.Controller/IServerApplicationPaths.cs@@ -59,12 +59,6 @@ namespace MediaBrowser.Controller/// <value>The game genre path.</value>string GameGenrePath { get; }- /// <summary>- /// Gets the artists path.- /// </summary>- /// <value>The artists path.</value>- string ArtistsPath { get; }-/// <summary>/// Gets the path to the Studio directory/// </summary>diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.csindex b95d67ad82..f29204689f 100644--- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs+++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs@@ -1,8 +1,8 @@using MediaBrowser.Controller.Entities.Audio;using MediaBrowser.Model.Configuration;using MediaBrowser.Model.Entities;-using System.Linq;using MediaBrowser.Model.Users;+using System.Linq;namespace MediaBrowser.Controller.LiveTv{@@ -83,5 +83,10 @@ namespace MediaBrowser.Controller.LiveTv{return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);}++ protected override string GetInternalMetadataPath(string basePath)+ {+ return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"));+ }}}diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.csindex de72accff8..459ead16cb 100644--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs@@ -145,5 +145,10 @@ namespace MediaBrowser.Controller.LiveTvreturn list;}++ protected override string GetInternalMetadataPath(string basePath)+ {+ return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata");+ }}}diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.csindex 29b23a551e..74cf950d42 100644--- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs+++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs@@ -204,5 +204,10 @@ namespace MediaBrowser.Controller.LiveTv{return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);}++ protected override string GetInternalMetadataPath(string basePath)+ {+ return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"));+ }}}diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.csindex 6fc985643a..91edc06c11 100644--- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs+++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs@@ -83,5 +83,10 @@ namespace MediaBrowser.Controller.LiveTv{return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);}++ protected override string GetInternalMetadataPath(string basePath)+ {+ return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"));+ }}}diff --git a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.csindex 4a807df7ac..b18651a68f 100644--- a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs+++ b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs@@ -38,7 +38,8 @@ namespace MediaBrowser.Controller.MediaEncodingSubtitlePlaybackMode mode,string audioTrackLanguage){- streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages).ToList();+ streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages)+ .ToList();var full = streams.Where(s => !s.IsForced);@@ -81,11 +82,9 @@ namespace MediaBrowser.Controller.MediaEncodingprivate static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, List<string> languagePreferences){- var orderStreams = streams- .Where(i => i.Type == type);-// Give some preferance to external text subs for better performance- return orderStreams.OrderBy(i =>+ return streams.Where(i => i.Type == type)+ .OrderBy(i =>{var index = languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase));@@ -94,8 +93,7 @@ namespace MediaBrowser.Controller.MediaEncoding.ThenBy(i => i.IsDefault).ThenBy(i => i.IsTextSubtitleStream).ThenBy(i => i.IsExternal)- .ThenBy(i => i.Index)- .ToList();+ .ThenBy(i => i.Index);}}}diff --git a/MediaBrowser.Controller/Session/ISessionController.cs b/MediaBrowser.Controller/Session/ISessionController.csindex d6dd7698e6..a4badee473 100644--- a/MediaBrowser.Controller/Session/ISessionController.cs+++ b/MediaBrowser.Controller/Session/ISessionController.cs@@ -105,5 +105,15 @@ namespace MediaBrowser.Controller.Session/// <param name="cancellationToken">The cancellation token.</param>/// <returns>Task.</returns>Task SendServerRestartNotification(CancellationToken cancellationToken);++ /// <summary>+ /// Sends the message.+ /// </summary>+ /// <typeparam name="T"></typeparam>+ /// <param name="name">The name.</param>+ /// <param name="data">The data.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>Task.</returns>+ Task SendMessage<T>(string name, T data, CancellationToken cancellationToken);}}diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.csindex f0272b3350..1f273a3ee0 100644--- a/MediaBrowser.Controller/Session/ISessionManager.cs+++ b/MediaBrowser.Controller/Session/ISessionManager.cs@@ -170,6 +170,17 @@ namespace MediaBrowser.Controller.Session/// <returns>Task.</returns>Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken);+ /// <summary>+ /// Sends the message to user sessions.+ /// </summary>+ /// <typeparam name="T"></typeparam>+ /// <param name="userId">The user identifier.</param>+ /// <param name="name">The name.</param>+ /// <param name="data">The data.</param>+ /// <param name="cancellationToken">The cancellation token.</param>+ /// <returns>Task.</returns>+ Task SendMessageToUserSessions<T>(string userId, string name, T data, CancellationToken cancellationToken);+/// <summary>/// Sends the restart required message./// </summary>diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.csindex d8a2464d64..078d4d70ff 100644--- a/MediaBrowser.Controller/Session/SessionInfo.cs+++ b/MediaBrowser.Controller/Session/SessionInfo.cs@@ -160,6 +160,11 @@ namespace MediaBrowser.Controller.Session}}+ public bool ContainsUser(string userId)+ {+ return ContainsUser(new Guid(userId));+ }+public bool ContainsUser(Guid userId){return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId));diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.csindex 7517cea50d..31f1e0a883 100644--- a/MediaBrowser.Dlna/DlnaManager.cs+++ b/MediaBrowser.Dlna/DlnaManager.cs@@ -393,7 +393,7 @@ namespace MediaBrowser.Dlnathrow new ArgumentException("System profiles cannot be deleted.");}- File.Delete(info.Path);+ _fileSystem.DeleteFile(info.Path);}public void CreateProfile(DeviceProfile profile)@@ -432,9 +432,9 @@ namespace MediaBrowser.Dlnaif (!string.Equals(path, current.Path, StringComparison.Ordinal) &¤t.Info.Type != DeviceProfileType.System){- File.Delete(current.Path);+ _fileSystem.DeleteFile(current.Path);}-+_xmlSerializer.SerializeToFile(profile, path);}diff --git a/MediaBrowser.Dlna/PlayTo/PlayToController.cs b/MediaBrowser.Dlna/PlayTo/PlayToController.csindex 1989c437aa..202121f68b 100644--- a/MediaBrowser.Dlna/PlayTo/PlayToController.cs+++ b/MediaBrowser.Dlna/PlayTo/PlayToController.cs@@ -899,5 +899,11 @@ namespace MediaBrowser.Dlna.PlayToreturn request;}}++ public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken)+ {+ // Not supported or needed right now+ return Task.FromResult(true);+ }}}diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.csindex ecf5d72d5a..4db4cd4277 100644--- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs@@ -248,7 +248,7 @@ namespace MediaBrowser.MediaEncoding.Encoderprotected virtual void DeleteFiles(EncodingJob job){- File.Delete(job.OutputFilePath);+ FileSystem.DeleteFile(job.OutputFilePath);}private void OnTranscodeBeginning(EncodingJob job)diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.csindex 24b818f5a6..10d8112ff0 100644--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs@@ -459,7 +459,7 @@ namespace MediaBrowser.MediaEncoding.Subtitlestry{_logger.Info("Deleting converted subtitle due to failure: ", outputPath);- File.Delete(outputPath);+ _fileSystem.DeleteFile(outputPath);}catch (IOException ex){@@ -608,7 +608,7 @@ namespace MediaBrowser.MediaEncoding.Subtitlestry{_logger.Info("Deleting extracted subtitle due to failure: {0}", outputPath);- File.Delete(outputPath);+ _fileSystem.DeleteFile(outputPath);}catch (FileNotFoundException){diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex e30cf1789d..c4a9c5eeaf 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -73,6 +73,12 @@ namespace MediaBrowser.Model.Configuration/// </summary>/// <value><c>true</c> if [enable localized guids]; otherwise, <c>false</c>.</value>public bool EnableLocalizedGuids { get; set; }++ /// <summary>+ /// Gets or sets a value indicating whether [enable library metadata sub folder].+ /// </summary>+ /// <value><c>true</c> if [enable library metadata sub folder]; otherwise, <c>false</c>.</value>+ public bool EnableLibraryMetadataSubFolder { get; set; }/// <summary>/// Gets or sets the preferred metadata language.@@ -150,6 +156,8 @@ namespace MediaBrowser.Model.Configurationpublic bool EnableTvDbUpdates { get; set; }public bool EnableTmdbUpdates { get; set; }+ public bool StoreArtistsInMetadata { get; set; }+public bool EnableFanArtUpdates { get; set; }public string FanartApiKey { get; set; }diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.csindex 9e33c1c36f..aa49ee50d5 100644--- a/MediaBrowser.Model/Configuration/UserConfiguration.cs+++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs@@ -6,12 +6,6 @@ namespace MediaBrowser.Model.Configuration/// </summary>public class UserConfiguration{- /// <summary>- /// Gets or sets the max parental rating.- /// </summary>- /// <value>The max parental rating.</value>- public int? MaxParentalRating { get; set; }-/// <summary>/// Gets or sets a value indicating whether this instance is administrator./// </summary>@@ -36,22 +30,8 @@ namespace MediaBrowser.Model.Configuration/// <value>The subtitle language preference.</value>public string SubtitleLanguagePreference { get; set; }- /// <summary>- /// Gets or sets a value indicating whether this instance is hidden.- /// </summary>- /// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>- public bool IsHidden { get; set; }-- /// <summary>- /// Gets or sets a value indicating whether this instance is disabled.- /// </summary>- /// <value><c>true</c> if this instance is disabled; otherwise, <c>false</c>.</value>- public bool IsDisabled { get; set; }-public bool DisplayMissingEpisodes { get; set; }public bool DisplayUnairedEpisodes { get; set; }- public bool EnableRemoteControlOfOtherUsers { get; set; }- public bool EnableSharedDeviceControl { get; set; }public bool EnableLiveTvManagement { get; set; }public bool EnableLiveTvAccess { get; set; }@@ -61,9 +41,6 @@ namespace MediaBrowser.Model.Configurationpublic bool GroupMoviesIntoBoxSets { get; set; }- public string[] BlockedMediaFolders { get; set; }- public string[] BlockedChannels { get; set; }-public string[] DisplayChannelsWithinViews { get; set; }public string[] ExcludeFoldersFromGrouping { get; set; }@@ -82,12 +59,7 @@ namespace MediaBrowser.Model.Configurationpublic bool EnableCinemaMode { get; set; }- public AccessSchedule[] AccessSchedules { get; set; }-- public bool EnableUserPreferenceAccess { get; set; }-public string[] LatestItemsExcludes { get; set; }- public string[] BlockedTags { get; set; }public bool HasMigratedToPolicy { get; set; }@@ -100,14 +72,10 @@ namespace MediaBrowser.Model.ConfigurationEnableLiveTvManagement = true;EnableMediaPlayback = true;EnableLiveTvAccess = true;- EnableSharedDeviceControl = true;LatestItemsExcludes = new string[] { };OrderedViews = new string[] { };- BlockedMediaFolders = new string[] { };DisplayChannelsWithinViews = new string[] { };- BlockedTags = new string[] { };- BlockedChannels = new string[] { };BlockUnratedItems = new UnratedItem[] { };ExcludeFoldersFromGrouping = new string[] { };@@ -115,9 +83,6 @@ namespace MediaBrowser.Model.ConfigurationIncludeTrailersInSuggestions = true;EnableCinemaMode = true;- EnableUserPreferenceAccess = true;-- AccessSchedules = new AccessSchedule[] { };}}}diff --git a/MediaBrowser.Model/Connect/ConnectAuthorization.cs b/MediaBrowser.Model/Connect/ConnectAuthorization.csindex 0c545f4bac..9e4537d65a 100644--- a/MediaBrowser.Model/Connect/ConnectAuthorization.cs+++ b/MediaBrowser.Model/Connect/ConnectAuthorization.cs@@ -9,12 +9,12 @@ namespace MediaBrowser.Model.Connectpublic string Id { get; set; }public string[] ExcludedLibraries { get; set; }public bool EnableLiveTv { get; set; }- public string[] ExcludedChannels { get; set; }+ public string[] EnabledChannels { get; set; }public ConnectAuthorization(){ExcludedLibraries = new string[] { };- ExcludedChannels = new string[] { };+ EnabledChannels = new string[] { };}}}diff --git a/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs b/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.csindex d40d353f01..77c574f8bd 100644--- a/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs+++ b/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs@@ -7,12 +7,12 @@ namespace MediaBrowser.Model.Connectpublic string ConnectUserName { get; set; }public string[] ExcludedLibraries { get; set; }public bool EnableLiveTv { get; set; }- public string[] ExcludedChannels { get; set; }+ public string[] EnabledChannels { get; set; }public ConnectAuthorizationRequest(){ExcludedLibraries = new string[] { };- ExcludedChannels = new string[] { };+ EnabledChannels = new string[] { };}}}diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.csindex 0a6a37696b..12b8c40715 100644--- a/MediaBrowser.Model/Users/UserPolicy.cs+++ b/MediaBrowser.Model/Users/UserPolicy.cs@@ -52,6 +52,9 @@ namespace MediaBrowser.Model.Userspublic string[] EnabledDevices { get; set; }public bool EnableAllDevices { get; set; }+ public string[] EnabledChannels { get; set; }+ public bool EnableAllChannels { get; set; }+public UserPolicy(){EnableLiveTvManagement = true;@@ -61,7 +64,6 @@ namespace MediaBrowser.Model.UsersBlockedMediaFolders = new string[] { };BlockedTags = new string[] { };- BlockedChannels = new string[] { };BlockUnratedItems = new UnratedItem[] { };EnableUserPreferenceAccess = true;diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.csindex 700bca0fab..6175587a72 100644--- a/MediaBrowser.Providers/Manager/ImageSaver.cs+++ b/MediaBrowser.Providers/Manager/ImageSaver.cs@@ -183,7 +183,7 @@ namespace MediaBrowser.Providers.ManagercurrentFile.Attributes &= ~FileAttributes.Hidden;}- currentFile.Delete();+ _fileSystem.DeleteFile(currentFile.FullName);}}finallydiff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.csindex 0d318c3773..66b0f92597 100644--- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs+++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs@@ -349,7 +349,7 @@ namespace MediaBrowser.Providers.ManagercurrentFile.Attributes &= ~FileAttributes.Hidden;}- currentFile.Delete();+ _fileSystem.DeleteFile(currentFile.FullName);deleted = true;}}diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.csindex 9a16ae24d9..187f8814bc 100644--- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs+++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs@@ -245,7 +245,7 @@ namespace MediaBrowser.Providers.Subtitlestry{- File.Delete(path);+ _fileSystem.DeleteFile(path);}finally{diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.csindex 20dc6c4859..fa49afbe97 100644--- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs+++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs@@ -1108,7 +1108,7 @@ namespace MediaBrowser.Providers.TV.EnumerateFiles("*.xml", SearchOption.AllDirectories).ToList()){- file.Delete();+ _fileSystem.DeleteFile(file.FullName);}}catch (DirectoryNotFoundException)diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs b/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.csindex 7179395b4d..0e0e4fbcb6 100644--- a/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs+++ b/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs@@ -96,7 +96,7 @@ namespace MediaBrowser.Server.Implementations.Channelspublic static string GetUserDistinctValue(User user){- var channels = user.Policy.BlockedChannels+ var channels = user.Policy.EnabledChannels.OrderBy(i => i).ToList();@@ -374,7 +374,7 @@ namespace MediaBrowser.Server.Implementations.Channels{try{- File.Delete(path);+ _fileSystem.DeleteFile(path);}catch (IOException ex){diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.csindex c12a1161ba..1130a510c5 100644--- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs+++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs@@ -1492,7 +1492,7 @@ namespace MediaBrowser.Server.Implementations.Channels}else{- File.Delete(response.TempFilePath);+ _fileSystem.DeleteFile(response.TempFilePath);throw new ApplicationException("Unexpected response type encountered: " + response.ContentType);}@@ -1501,7 +1501,7 @@ namespace MediaBrowser.Server.Implementations.Channelstry{- File.Delete(response.TempFilePath);+ _fileSystem.DeleteFile(response.TempFilePath);}catch{diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.csindex 9fee27db9b..05efcaa1c9 100644--- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs+++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs@@ -258,7 +258,7 @@ namespace MediaBrowser.Server.Implementations.Collections{foreach (var file in shortcutFilesToDelete){- File.Delete(file);+ _fileSystem.DeleteFile(file);}foreach (var child in list)diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.csindex 67d8445438..b703b204ee 100644--- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs+++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs@@ -548,7 +548,7 @@ namespace MediaBrowser.Server.Implementations.ConnectImageUrl = response.UserImageUrl,UserName = response.UserName,ExcludedLibraries = request.ExcludedLibraries,- ExcludedChannels = request.ExcludedChannels,+ EnabledChannels = request.EnabledChannels,EnableLiveTv = request.EnableLiveTv,AccessToken = accessToken});@@ -810,7 +810,8 @@ namespace MediaBrowser.Server.Implementations.Connect{user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;user.Policy.BlockedMediaFolders = currentPendingEntry.ExcludedLibraries;- user.Policy.BlockedChannels = currentPendingEntry.ExcludedChannels;+ user.Policy.EnabledChannels = currentPendingEntry.EnabledChannels;+ user.Policy.EnableAllChannels = false;}await _userManager.UpdateConfiguration(user.Id.ToString("N"), user.Configuration);@@ -937,7 +938,7 @@ namespace MediaBrowser.Server.Implementations.Connect{ConnectUserId = i.ConnectUserId,EnableLiveTv = i.EnableLiveTv,- ExcludedChannels = i.ExcludedChannels,+ EnabledChannels = i.EnabledChannels,ExcludedLibraries = i.ExcludedLibraries,Id = i.Id,ImageUrl = i.ImageUrl,diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.csindex d587e5af73..70a04d2494 100644--- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs+++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs@@ -1,5 +1,6 @@using MediaBrowser.Common.Configuration;using MediaBrowser.Common.Extensions;+using MediaBrowser.Common.IO;using MediaBrowser.Controller.Devices;using MediaBrowser.Model.Devices;using MediaBrowser.Model.Logging;@@ -21,14 +22,16 @@ namespace MediaBrowser.Server.Implementations.Devicesprivate readonly IApplicationPaths _appPaths;private readonly IJsonSerializer _json;private readonly ILogger _logger;+ private readonly IFileSystem _fileSystem;private ConcurrentBag<DeviceInfo> _devices;- public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger)+ public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem){_appPaths = appPaths;_json = json;_logger = logger;+ _fileSystem = fileSystem;}private string GetDevicesPath()@@ -129,12 +132,12 @@ namespace MediaBrowser.Server.Implementations.Devices{try{- Directory.Delete(path, true);+ _fileSystem.DeleteDirectory(path, true);}catch (DirectoryNotFoundException){}-+_devices = null;}diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.csindex 1eb4a66552..bc10253058 100644--- a/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs+++ b/MediaBrowser.Server.Implementations/EntryPoints/ServerEventNotifier.cs@@ -2,7 +2,6 @@using MediaBrowser.Common.ScheduledTasks;using MediaBrowser.Common.Updates;using MediaBrowser.Controller;-using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Net;@@ -44,28 +43,15 @@ namespace MediaBrowser.Server.Implementations.EntryPoints/// </summary>private readonly ITaskManager _taskManager;- private readonly IDtoService _dtoService;-private readonly ISessionManager _sessionManager;- /// <summary>- /// Initializes a new instance of the <see cref="ServerEventNotifier" /> class.- /// </summary>- /// <param name="serverManager">The server manager.</param>- /// <param name="appHost">The application host.</param>- /// <param name="userManager">The user manager.</param>- /// <param name="installationManager">The installation manager.</param>- /// <param name="taskManager">The task manager.</param>- /// <param name="dtoService">The dto service.</param>- /// <param name="sessionManager">The session manager.</param>- public ServerEventNotifier(IServerManager serverManager, IServerApplicationHost appHost, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager, IDtoService dtoService, ISessionManager sessionManager)+ public ServerEventNotifier(IServerManager serverManager, IServerApplicationHost appHost, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager, ISessionManager sessionManager){_serverManager = serverManager;_userManager = userManager;_installationManager = installationManager;_appHost = appHost;_taskManager = taskManager;- _dtoService = dtoService;_sessionManager = sessionManager;}@@ -86,13 +72,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints_taskManager.TaskCompleted += _taskManager_TaskCompleted;}- void _userManager_UserConfigurationUpdated(object sender, GenericEventArgs<User> e)- {- var dto = _userManager.GetUserDto(e.Argument);-- _serverManager.SendWebSocketMessage("UserConfigurationUpdated", dto);- }-void _installationManager_PackageInstalling(object sender, InstallationEventArgs e){_serverManager.SendWebSocketMessage("PackageInstalling", e.InstallationInfo);@@ -146,8 +125,8 @@ namespace MediaBrowser.Server.Implementations.EntryPointsvoid userManager_UserUpdated(object sender, GenericEventArgs<User> e){var dto = _userManager.GetUserDto(e.Argument);-- _serverManager.SendWebSocketMessage("UserUpdated", dto);++ SendMessageToUserSession(e.Argument, "UserUpdated", dto);}/// <summary>@@ -157,7 +136,19 @@ namespace MediaBrowser.Server.Implementations.EntryPoints/// <param name="e">The e.</param>void userManager_UserDeleted(object sender, GenericEventArgs<User> e){- _serverManager.SendWebSocketMessage("UserDeleted", e.Argument.Id.ToString("N"));+ SendMessageToUserSession(e.Argument, "UserDeleted", e.Argument.Id.ToString("N"));+ }++ void _userManager_UserConfigurationUpdated(object sender, GenericEventArgs<User> e)+ {+ var dto = _userManager.GetUserDto(e.Argument);++ SendMessageToUserSession(e.Argument, "UserConfigurationUpdated", dto);+ }++ private async void SendMessageToUserSession<T>(User user, string name, T data)+ {+ await _sessionManager.SendMessageToUserSessions(user.Id.ToString("N"), name, data, CancellationToken.None);}/// <summary>diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.csindex c31f462150..ccd427a47e 100644--- a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs+++ b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs@@ -108,7 +108,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints{var userId = pair.Key;var userSessions = _sessionManager.Sessions- .Where(u => u.UserId.HasValue && u.UserId.Value == userId && u.SessionController != null && u.IsActive)+ .Where(u => u.ContainsUser(userId) && u.SessionController != null && u.IsActive).ToList();if (userSessions.Count > 0)diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.csindex 611f887eed..cfc3e2b234 100644--- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs+++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs@@ -209,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganizationtry{- File.Delete(path);+ _fileSystem.DeleteFile(path);}catch (IOException ex){@@ -315,7 +315,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization{try{- File.Delete(result.OriginalPath);+ _fileSystem.DeleteFile(result.OriginalPath);}catch (Exception ex){diff --git a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.csindex 7c52696787..a6116ab096 100644--- a/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs+++ b/MediaBrowser.Server.Implementations/FileOrganization/FileOrganizationService.cs@@ -85,7 +85,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization_logger.Info("Requested to delete {0}", result.OriginalPath);try{- File.Delete(result.OriginalPath);+ _fileSystem.DeleteFile(result.OriginalPath);}catch (Exception ex){diff --git a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.csindex cf120f1476..e3c8e6d257 100644--- a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs+++ b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs@@ -166,7 +166,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization{try{- File.Delete(file.FullName);+ _fileSystem.DeleteFile(file.FullName);}catch (Exception ex){diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.csindex 226d97b3cd..2c8413f5e3 100644--- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs@@ -556,31 +556,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharpreturn (stream);}}-- public void SaveAs(string filename)- {- byte[] buffer = new byte[16 * 1024];- long old_post = stream.Position;-- try- {- File.Delete(filename);- using (FileStream fs = File.Create(filename))- {- stream.Position = 0;- int n;-- while ((n = stream.Read(buffer, 0, 16 * 1024)) != 0)- {- fs.Write(buffer, 0, n);- }- }- }- finally- {- stream.Position = old_post;- }- }}class Helpersdiff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.csindex 597dcd9af8..cceccceacf 100644--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs@@ -401,11 +401,11 @@ namespace MediaBrowser.Server.Implementations.Librarytry{- Directory.Delete(metadataPath, true);+ _fileSystem.DeleteDirectory(metadataPath, true);}catch (DirectoryNotFoundException){-+}catch (Exception ex){@@ -420,12 +420,12 @@ namespace MediaBrowser.Server.Implementations.Libraryif (Directory.Exists(path)){_logger.Debug("Deleting path {0}", path);- Directory.Delete(path, true);+ _fileSystem.DeleteDirectory(path, true);}else if (File.Exists(path)){_logger.Debug("Deleting path {0}", path);- File.Delete(path);+ _fileSystem.DeleteFile(path);}}@@ -840,6 +840,23 @@ namespace MediaBrowser.Server.Implementations.Libraryreturn GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture));}+ /// <summary>+ /// Gets the artists path.+ /// </summary>+ /// <value>The artists path.</value>+ public string ArtistsPath+ {+ get+ {+ if (ConfigurationManager.Configuration.StoreArtistsInMetadata)+ {+ return Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "artists");+ }++ return Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath, "artists");+ }+ }+/// <summary>/// Gets a Genre/// </summary>@@ -847,7 +864,7 @@ namespace MediaBrowser.Server.Implementations.Library/// <returns>Task{Genre}.</returns>public MusicArtist GetArtist(string name){- return GetItemByName<MusicArtist>(ConfigurationManager.ApplicationPaths.ArtistsPath, name);+ return GetItemByName<MusicArtist>(ArtistsPath, name);}private T GetItemByName<T>(string path, string name)@@ -976,7 +993,7 @@ namespace MediaBrowser.Server.Implementations.Librarypublic Task ValidateArtists(CancellationToken cancellationToken, IProgress<double> progress){// Ensure the location is unavailable.- Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.ArtistsPath);+ Directory.CreateDirectory(ArtistsPath);return new ArtistsValidator(this, _userManager, _logger).Run(progress, cancellationToken);}diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.csindex 3b6de5998f..b51a9ee7cd 100644--- a/MediaBrowser.Server.Implementations/Library/UserManager.cs+++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs@@ -1,7 +1,9 @@using MediaBrowser.Common.Events;using MediaBrowser.Common.Extensions;+using MediaBrowser.Common.IO;using MediaBrowser.Common.Net;using MediaBrowser.Controller;+using MediaBrowser.Controller.Channels;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Connect;using MediaBrowser.Controller.Drawing;@@ -11,6 +13,7 @@ using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Net;using MediaBrowser.Controller.Persistence;using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Channels;using MediaBrowser.Model.Configuration;using MediaBrowser.Model.Connect;using MediaBrowser.Model.Dto;@@ -69,9 +72,11 @@ namespace MediaBrowser.Server.Implementations.Libraryprivate readonly Func<IImageProcessor> _imageProcessorFactory;private readonly Func<IDtoService> _dtoServiceFactory;private readonly Func<IConnectManager> _connectFactory;+ private readonly Func<IChannelManager> _channelManager;private readonly IServerApplicationHost _appHost;+ private readonly IFileSystem _fileSystem;- public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer)+ public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager){_logger = logger;UserRepository = userRepository;@@ -82,6 +87,8 @@ namespace MediaBrowser.Server.Implementations.Library_connectFactory = connectFactory;_appHost = appHost;_jsonSerializer = jsonSerializer;+ _fileSystem = fileSystem;+ _channelManager = channelManager;ConfigurationManager = configurationManager;Users = new List<User>();@@ -165,6 +172,7 @@ namespace MediaBrowser.Server.Implementations.Libraryforeach (var user in users){await DoPolicyMigration(user).ConfigureAwait(false);+ await DoChannelMigration(user).ConfigureAwait(false);}// If there are no local users with admin rights, make them all admins@@ -204,7 +212,7 @@ namespace MediaBrowser.Server.Implementations.Library{return username;}-+// Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)var builder = new StringBuilder();@@ -329,22 +337,12 @@ namespace MediaBrowser.Server.Implementations.Library{if (!user.Configuration.HasMigratedToPolicy){- user.Policy.AccessSchedules = user.Configuration.AccessSchedules;- user.Policy.BlockedChannels = user.Configuration.BlockedChannels;- user.Policy.BlockedMediaFolders = user.Configuration.BlockedMediaFolders;- user.Policy.BlockedTags = user.Configuration.BlockedTags;user.Policy.BlockUnratedItems = user.Configuration.BlockUnratedItems;user.Policy.EnableContentDeletion = user.Configuration.EnableContentDeletion;user.Policy.EnableLiveTvAccess = user.Configuration.EnableLiveTvAccess;user.Policy.EnableLiveTvManagement = user.Configuration.EnableLiveTvManagement;user.Policy.EnableMediaPlayback = user.Configuration.EnableMediaPlayback;- user.Policy.EnableRemoteControlOfOtherUsers = user.Configuration.EnableRemoteControlOfOtherUsers;- user.Policy.EnableSharedDeviceControl = user.Configuration.EnableSharedDeviceControl;- user.Policy.EnableUserPreferenceAccess = user.Configuration.EnableUserPreferenceAccess;user.Policy.IsAdministrator = user.Configuration.IsAdministrator;- user.Policy.IsDisabled = user.Configuration.IsDisabled;- user.Policy.IsHidden = user.Configuration.IsHidden;- user.Policy.MaxParentalRating = user.Configuration.MaxParentalRating;await UpdateUserPolicy(user, user.Policy, false);@@ -353,6 +351,44 @@ namespace MediaBrowser.Server.Implementations.Library}}+ private async Task DoChannelMigration(User user)+ {+ if (user.Policy.BlockedChannels != null)+ {+ if (user.Policy.BlockedChannels.Length > 0)+ {+ user.Policy.EnableAllChannels = false;++ try+ {+ var channelResult = await _channelManager().GetChannelsInternal(new ChannelQuery+ {+ UserId = user.Id.ToString("N")++ }, CancellationToken.None).ConfigureAwait(false);++ user.Policy.EnabledChannels = channelResult.Items+ .Select(i => i.Id.ToString("N"))+ .Except(user.Policy.BlockedChannels)+ .ToArray();+ }+ catch+ {+ user.Policy.EnabledChannels = new string[] { };+ }+ }+ else+ {+ user.Policy.EnableAllChannels = true;+ user.Policy.EnabledChannels = new string[] { };+ }++ user.Policy.BlockedChannels = null;++ await UpdateUserPolicy(user, user.Policy, false);+ }+ }+public UserDto GetUserDto(User user, string remoteEndPoint = null){if (user == null)@@ -591,7 +627,7 @@ namespace MediaBrowser.Server.Implementations.Librarytry{- File.Delete(configPath);+ _fileSystem.DeleteFile(configPath);}catch (IOException ex){@@ -817,7 +853,7 @@ namespace MediaBrowser.Server.Implementations.Library{try{- File.Delete(PasswordResetFile);+ _fileSystem.DeleteFile(PasswordResetFile);}catch{@@ -881,7 +917,7 @@ namespace MediaBrowser.Server.Implementations.Libraryvar json = _jsonSerializer.SerializeToString(userPolicy);userPolicy = _jsonSerializer.DeserializeFromString<UserPolicy>(json);}-+var path = GetPolifyFilePath(user);Directory.CreateDirectory(Path.GetDirectoryName(path));@@ -909,7 +945,7 @@ namespace MediaBrowser.Server.Implementations.Library{lock (_policySyncLock){- File.Delete(path);+ _fileSystem.DeleteFile(path);}}catch (IOException)@@ -971,14 +1007,14 @@ namespace MediaBrowser.Server.Implementations.Libraryvar path = GetConfigurationFilePath(user);// The xml serializer will output differently if the type is not exact- if (config.GetType() != typeof (UserConfiguration))+ if (config.GetType() != typeof(UserConfiguration)){var json = _jsonSerializer.SerializeToString(config);config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);}Directory.CreateDirectory(Path.GetDirectoryName(path));-+lock (_configSyncLock){_xmlSerializer.SerializeToFile(config, path);diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.jsonindex 943daff5ef..8acce7b725 100644--- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json+++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json@@ -42,6 +42,7 @@"LabelFailed": "(failed)","ButtonHelp": "Help","ButtonSave": "Save",+ "HeaderDevices": "Devices","HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more. {0}Learn more{1}.","HeaderWelcomeToMediaBrowserServerDashboard": "Welcome to the Media Browser Dashboard","HeaderWelcomeToMediaBrowserWebClient": "Welcome to the Media Browser Web Client",diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.jsonindex e3add2f19b..7bd42507d2 100644--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json@@ -86,6 +86,7 @@"TabCollectionTitles": "Titles","HeaderDeviceAccess": "Device Access","OptionEnableAccessFromAllDevices": "Enable access from all devices",+ "OptionEnableAccessToAllChannels": "Enable access to all channels","DeviceAccessHelp": "This only applies to devices that can be uniquely identified and will not prevent browser access. Filtering user device access will prevent them from using new devices until they've been approved here.","LabelDisplayMissingEpisodesWithinSeasons": "Display missing episodes within seasons","LabelUnairedMissingEpisodesWithinSeasons": "Display unaired episodes within seasons",diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.csindex a0b6046453..56557d6e1d 100644--- a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs+++ b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs@@ -215,7 +215,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncodertry{- File.Delete(image);+ _fileSystem.DeleteFile(image);}catch (IOException ex){diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.csindex d9973afe78..8a04f29a2c 100644--- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs+++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs@@ -197,19 +197,6 @@ namespace MediaBrowser.Server.Implementations}}- /// <summary>- /// Gets the artists path.- /// </summary>- /// <value>The artists path.</value>- public string ArtistsPath- {- get- {- return Path.Combine(ItemsByNamePath, "artists");- }- }--/// <summary>/// Gets the game genre path./// </summary>diff --git a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs b/MediaBrowser.Server.Implementations/Session/HttpSessionController.csindex 4a64d37532..4d5c408535 100644--- a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs+++ b/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs@@ -209,6 +209,12 @@ namespace MediaBrowser.Server.Implementations.Sessionreturn SendMessage(command.Name, command.Arguments, cancellationToken);}+ public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken)+ {+ // Not supported or needed right now+ return Task.FromResult(true);+ }+private string ToQueryString(Dictionary<string, string> nvc){var array = (from item in nvcdiff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.csindex d9ec9b7e4d..8bf39fd6b9 100644--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs@@ -1632,5 +1632,26 @@ namespace MediaBrowser.Server.Implementations.Sessionreturn Sessions.FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) &&string.Equals(i.Client, client));}++ public Task SendMessageToUserSessions<T>(string userId, string name, T data,+ CancellationToken cancellationToken)+ {+ var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null && i.ContainsUser(userId)).ToList();++ var tasks = sessions.Select(session => Task.Run(async () =>+ {+ try+ {+ await session.SessionController.SendMessage(name, data, cancellationToken).ConfigureAwait(false);+ }+ catch (Exception ex)+ {+ _logger.ErrorException("Error in SendPlaybackStoppedNotification.", ex);+ }++ }, cancellationToken));++ return Task.WhenAll(tasks);+ }}}\ No newline at end of filediff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.csindex 7d1057397e..19aaaf8a55 100644--- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs+++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs@@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendPlayCommand(PlayRequest command, CancellationToken cancellationToken){- return SendMessage(new WebSocketMessage<PlayRequest>+ return SendMessageInternal(new WebSocketMessage<PlayRequest>{MessageType = "Play",Data = command@@ -100,7 +100,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendPlaystateCommand(PlaystateRequest command, CancellationToken cancellationToken){- return SendMessage(new WebSocketMessage<PlaystateRequest>+ return SendMessageInternal(new WebSocketMessage<PlaystateRequest>{MessageType = "Playstate",Data = command@@ -110,7 +110,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendLibraryUpdateInfo(LibraryUpdateInfo info, CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<LibraryUpdateInfo>+ return SendMessagesInternal(new WebSocketMessage<LibraryUpdateInfo>{MessageType = "LibraryChanged",Data = info@@ -126,7 +126,7 @@ namespace MediaBrowser.Server.Implementations.Session/// <returns>Task.</returns>public Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<SystemInfo>+ return SendMessagesInternal(new WebSocketMessage<SystemInfo>{MessageType = "RestartRequired",Data = info@@ -143,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Session/// <returns>Task.</returns>public Task SendUserDataChangeInfo(UserDataChangeInfo info, CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<UserDataChangeInfo>+ return SendMessagesInternal(new WebSocketMessage<UserDataChangeInfo>{MessageType = "UserDataChanged",Data = info@@ -158,7 +158,7 @@ namespace MediaBrowser.Server.Implementations.Session/// <returns>Task.</returns>public Task SendServerShutdownNotification(CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<string>+ return SendMessagesInternal(new WebSocketMessage<string>{MessageType = "ServerShuttingDown",Data = string.Empty@@ -173,7 +173,7 @@ namespace MediaBrowser.Server.Implementations.Session/// <returns>Task.</returns>public Task SendServerRestartNotification(CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<string>+ return SendMessagesInternal(new WebSocketMessage<string>{MessageType = "ServerRestarting",Data = string.Empty@@ -183,7 +183,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken){- return SendMessage(new WebSocketMessage<GeneralCommand>+ return SendMessageInternal(new WebSocketMessage<GeneralCommand>{MessageType = "GeneralCommand",Data = command@@ -193,7 +193,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendSessionEndedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<SessionInfoDto>+ return SendMessagesInternal(new WebSocketMessage<SessionInfoDto>{MessageType = "SessionEnded",Data = sessionInfo@@ -203,7 +203,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendPlaybackStartNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<SessionInfoDto>+ return SendMessagesInternal(new WebSocketMessage<SessionInfoDto>{MessageType = "PlaybackStart",Data = sessionInfo@@ -213,7 +213,7 @@ namespace MediaBrowser.Server.Implementations.Sessionpublic Task SendPlaybackStoppedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken){- return SendMessages(new WebSocketMessage<SessionInfoDto>+ return SendMessagesInternal(new WebSocketMessage<SessionInfoDto>{MessageType = "PlaybackStopped",Data = sessionInfo@@ -221,7 +221,17 @@ namespace MediaBrowser.Server.Implementations.Session}, cancellationToken);}- private Task SendMessage<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)+ public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken)+ {+ return SendMessagesInternal(new WebSocketMessage<T>+ {+ Data = data,+ MessageType = name++ }, cancellationToken);+ }++ private Task SendMessageInternal<T>(WebSocketMessage<T> message, CancellationToken cancellationToken){if (SkipSending()) return Task.FromResult(true);@@ -230,7 +240,7 @@ namespace MediaBrowser.Server.Implementations.Sessionreturn socket.SendAsync(message, cancellationToken);}- private Task SendMessages<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)+ private Task SendMessagesInternal<T>(WebSocketMessage<T> message, CancellationToken cancellationToken){if (SkipSending()) return Task.FromResult(true);diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.csindex b8f199e6bc..33db54ee1b 100644--- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs+++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs@@ -1,5 +1,6 @@using MediaBrowser.Common;using MediaBrowser.Common.Extensions;+using MediaBrowser.Common.IO;using MediaBrowser.Controller.Channels;using MediaBrowser.Controller.Drawing;using MediaBrowser.Controller.Dto;@@ -37,10 +38,11 @@ namespace MediaBrowser.Server.Implementations.Syncprivate readonly IApplicationHost _appHost;private readonly ITVSeriesManager _tvSeriesManager;private readonly Func<IMediaEncoder> _mediaEncoder;+ private readonly IFileSystem _fileSystem;private ISyncProvider[] _providers = { };- public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func<IMediaEncoder> mediaEncoder)+ public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func<IMediaEncoder> mediaEncoder, IFileSystem fileSystem){_libraryManager = libraryManager;_repo = repo;@@ -51,6 +53,7 @@ namespace MediaBrowser.Server.Implementations.Sync_appHost = appHost;_tvSeriesManager = tvSeriesManager;_mediaEncoder = mediaEncoder;+ _fileSystem = fileSystem;}public void AddParts(IEnumerable<ISyncProvider> providers)@@ -396,7 +399,7 @@ namespace MediaBrowser.Server.Implementations.Sync{try{- File.Delete(jobItem.OutputPath);+ _fileSystem.DeleteFile(jobItem.OutputPath);}catch (Exception ex){diff --git a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.csindex c2925551b7..068261ffd3 100644--- a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs+++ b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs@@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Implementations.Syncpublic bool IsHidden{- get { return true; }+ get { return false; }}public bool IsEnableddiff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex 013e9205ab..6545398702 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -365,11 +365,11 @@ namespace MediaBrowser.Server.Startup.Common{var migrations = new List<IVersionMigration>{- new MigrateUserFolders(ApplicationPaths),+ new MigrateUserFolders(ApplicationPaths, FileSystemManager),new RenameXbmcOptions(ServerConfigurationManager),new RenameXmlOptions(ServerConfigurationManager),- new DeprecatePlugins(ApplicationPaths),- new DeleteDlnaProfiles(ApplicationPaths)+ new DeprecatePlugins(ApplicationPaths, FileSystemManager),+ new DeleteDlnaProfiles(ApplicationPaths, FileSystemManager)};foreach (var task in migrations)@@ -435,7 +435,7 @@ namespace MediaBrowser.Server.Startup.CommonSyncRepository = await GetSyncRepository().ConfigureAwait(false);RegisterSingleInstance(SyncRepository);- UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer);+ UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, () => ChannelManager);RegisterSingleInstance(UserManager);LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);@@ -483,7 +483,7 @@ namespace MediaBrowser.Server.Startup.CommonTVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);RegisterSingleInstance(TVSeriesManager);- SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder);+ SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager);RegisterSingleInstance(SyncManager);DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this);@@ -495,7 +495,7 @@ namespace MediaBrowser.Server.Startup.CommonConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager);RegisterSingleInstance(ConnectManager);- DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));+ DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger, FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));RegisterSingleInstance(DeviceManager);SessionManager = new SessionManager(UserDataManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.csindex 229fee18d8..58e8e2da8e 100644--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs@@ -129,7 +129,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg{try{- Directory.Delete(path, true);+ _fileSystem.DeleteDirectory(path, true);}catch (Exception ex){@@ -272,7 +272,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg{try{- File.Delete(path);+ _fileSystem.DeleteFile(path);}catch (IOException ex){@@ -380,10 +380,10 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg}Extract7zArchive(tempFile, fontsDirectory);-+try{- File.Delete(tempFile);+ _fileSystem.DeleteFile(tempFile);}catch (IOException ex){diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DeleteDlnaProfiles.cs b/MediaBrowser.Server.Startup.Common/Migrations/DeleteDlnaProfiles.csindex 8fe841ffce..166c2627f1 100644--- a/MediaBrowser.Server.Startup.Common/Migrations/DeleteDlnaProfiles.cs+++ b/MediaBrowser.Server.Startup.Common/Migrations/DeleteDlnaProfiles.cs@@ -1,4 +1,5 @@-using MediaBrowser.Controller;+using MediaBrowser.Common.IO;+using MediaBrowser.Controller;using System.IO;namespace MediaBrowser.Server.Startup.Common.Migrations@@ -6,10 +7,12 @@ namespace MediaBrowser.Server.Startup.Common.Migrationspublic class DeleteDlnaProfiles : IVersionMigration{private readonly IServerApplicationPaths _appPaths;+ private readonly IFileSystem _fileSystem;- public DeleteDlnaProfiles(IServerApplicationPaths appPaths)+ public DeleteDlnaProfiles(IServerApplicationPaths appPaths, IFileSystem fileSystem){_appPaths = appPaths;+ _fileSystem = fileSystem;}public void Run()@@ -23,7 +26,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations{try{- File.Delete(Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system", filename + ".xml"));+ _fileSystem.DeleteFile(Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system", filename + ".xml"));}catch{@@ -31,7 +34,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations}try{- File.Delete(Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user", filename + ".xml"));+ _fileSystem.DeleteFile(Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user", filename + ".xml"));}catch{diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DeprecatePlugins.cs b/MediaBrowser.Server.Startup.Common/Migrations/DeprecatePlugins.csindex ce4665b26c..afdd4e623f 100644--- a/MediaBrowser.Server.Startup.Common/Migrations/DeprecatePlugins.cs+++ b/MediaBrowser.Server.Startup.Common/Migrations/DeprecatePlugins.cs@@ -1,4 +1,5 @@-using MediaBrowser.Controller;+using MediaBrowser.Common.IO;+using MediaBrowser.Controller;using System.IO;namespace MediaBrowser.Server.Startup.Common.Migrations@@ -6,10 +7,12 @@ namespace MediaBrowser.Server.Startup.Common.Migrationspublic class DeprecatePlugins : IVersionMigration{private readonly IServerApplicationPaths _appPaths;+ private readonly IFileSystem _fileSystem;- public DeprecatePlugins(IServerApplicationPaths appPaths)+ public DeprecatePlugins(IServerApplicationPaths appPaths, IFileSystem fileSystem){_appPaths = appPaths;+ _fileSystem = fileSystem;}public void Run()@@ -21,7 +24,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations{try{- File.Delete(Path.Combine(_appPaths.PluginsPath, filename));+ _fileSystem.DeleteFile(Path.Combine(_appPaths.PluginsPath, filename));}catch{diff --git a/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs b/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.csindex 5e3df5701e..cb566d6cf8 100644--- a/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs+++ b/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs@@ -1,4 +1,5 @@-using MediaBrowser.Controller;+using MediaBrowser.Common.IO;+using MediaBrowser.Controller;using System;using System.IO;using System.Linq;@@ -8,10 +9,12 @@ namespace MediaBrowser.Server.Startup.Common.Migrationspublic class MigrateUserFolders : IVersionMigration{private readonly IServerApplicationPaths _appPaths;+ private readonly IFileSystem _fileSystem;- public MigrateUserFolders(IServerApplicationPaths appPaths)+ public MigrateUserFolders(IServerApplicationPaths appPaths, IFileSystem fileSystem){_appPaths = appPaths;+ _fileSystem = fileSystem;}public void Run()@@ -25,7 +28,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrationsforeach (var folder in folders){- Directory.Delete(folder.FullName, true);+ _fileSystem.DeleteDirectory(folder.FullName, true);}}catch (IOException)diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.csindex adc8eecb1d..7532a2edd3 100644--- a/MediaBrowser.ServerApplication/MainStartup.cs+++ b/MediaBrowser.ServerApplication/MainStartup.cs@@ -203,7 +203,7 @@ namespace MediaBrowser.ServerApplication{var fileSystem = new NativeFileSystem(logManager.GetLogger("FileSystem"), false);- var nativeApp = new WindowsApp+ var nativeApp = new WindowsApp(fileSystem){IsRunningAsService = runService};diff --git a/MediaBrowser.ServerApplication/Native/Autorun.cs b/MediaBrowser.ServerApplication/Native/Autorun.csindex 0262f711e7..593bb7955c 100644--- a/MediaBrowser.ServerApplication/Native/Autorun.cs+++ b/MediaBrowser.ServerApplication/Native/Autorun.cs@@ -1,4 +1,5 @@-using System;+using MediaBrowser.Common.IO;+using System;using System.IO;namespace MediaBrowser.ServerApplication.Native@@ -12,7 +13,8 @@ namespace MediaBrowser.ServerApplication.Native/// Configures the specified autorun./// </summary>/// <param name="autorun">if set to <c>true</c> [autorun].</param>- public static void Configure(bool autorun)+ /// <param name="fileSystem">The file system.</param>+ public static void Configure(bool autorun, IFileSystem fileSystem){var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk");@@ -26,7 +28,7 @@ namespace MediaBrowser.ServerApplication.Nativeelse{//Remove our shortcut from the startup folder for this user- File.Delete(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk"));+ fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk"));}}}diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.csindex 45070e6ece..476fb58b9d 100644--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs@@ -1,4 +1,5 @@-using MediaBrowser.Common.Net;+using MediaBrowser.Common.IO;+using MediaBrowser.Common.Net;using MediaBrowser.IsoMounter;using MediaBrowser.Model.Logging;using MediaBrowser.Server.Startup.Common;@@ -10,6 +11,13 @@ namespace MediaBrowser.ServerApplication.Native{public class WindowsApp : INativeApp{+ private readonly IFileSystem _fileSystem;++ public WindowsApp(IFileSystem fileSystem)+ {+ _fileSystem = fileSystem;+ }+public List<Assembly> GetAssembliesWithParts(){var list = new List<Assembly>();@@ -89,7 +97,7 @@ namespace MediaBrowser.ServerApplication.Nativepublic void ConfigureAutoRun(bool autorun){- Autorun.Configure(autorun);+ Autorun.Configure(autorun, _fileSystem);}public INetworkManager CreateNetworkManager(ILogger logger)diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.csindex 6e34390797..74496ef9c6 100644--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs@@ -275,11 +275,11 @@ namespace MediaBrowser.WebDashboard.Apitry{- Directory.Delete(path, true);+ _fileSystem.DeleteDirectory(path, true);}catch (IOException){-+}var creator = GetPackageCreator();diff --git a/SharedVersion.cs b/SharedVersion.csindex 238d57f0ce..5af3efc1c8 100644--- a/SharedVersion.cs+++ b/SharedVersion.cs@@ -1,4 +1,4 @@using System.Reflection;-//[assembly: AssemblyVersion("3.0.*")]-[assembly: AssemblyVersion("3.0.5490.2")]+[assembly: AssemblyVersion("3.0.*")]+//[assembly: AssemblyVersion("3.0.5490.2")]