diff options
72 files changed, 399 insertions, 241 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 0eb92d5a7..a9b43090a 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.Api private 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.Api foreach (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.cs index 102e2d45e..a5ddcb6f1 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.Api ConnectUserName = 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.cs index e21dc4a73..0ee28d6fe 100644 --- a/MediaBrowser.Api/Library/LibraryHelpers.cs +++ b/MediaBrowser.Api/Library/LibraryHelpers.cs @@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Library if (!string.IsNullOrEmpty(shortcut)) { - File.Delete(shortcut); + fileSystem.DeleteFile(shortcut); } } diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index ee80d4b73..23f4e4e5c 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -348,7 +348,7 @@ namespace MediaBrowser.Api.Library try { - Directory.Delete(path, true); + _fileSystem.DeleteDirectory(path, true); // Need to add a delay here or directory watchers may still pick up the changes var delayTask = Task.Delay(1000); diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 86866bdf5..53229f031 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.cs index 87e2eedcf..514597c3e 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.cs index 59b8e85c2..e5fe69b62 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.cs index 4443b2a2b..97401bbf8 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.cs index c98a6bd6c..0f89bd1a6 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -475,7 +475,7 @@ namespace MediaBrowser.Common.Implementations SecurityManager = 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.cs index 1f82c5eb0..b925649fc 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.cs index 68df0e52a..c54b053fd 100644 --- a/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs +++ b/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs @@ -270,8 +270,8 @@ namespace MediaBrowser.Common.Implementations.IO File.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.cs index fcb7b159b..779f992d3 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.cs index 3b0c02dc6..6b9bcbfc1 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.Tasks cancellationToken.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.cs index 47215aacf..264e63b47 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.Updates private 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.Updates try { - 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.cs index 3bcec98ce..5ce84f436 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.cs index 5a9fc3322..6ee6fe006 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Channels public 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.cs index ee562d8b4..6a30df7fe 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -379,7 +379,14 @@ namespace MediaBrowser.Controller.Entities public 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.Entities currentFile.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.cs index 626afcfdf..869c30ba8 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 exist if (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.cs index e3438c3d2..c07934d0b 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -60,12 +60,6 @@ namespace MediaBrowser.Controller 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> /// <value>The studio path.</value> diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index b95d67ad8..f29204689 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.cs index de72accff..459ead16c 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -145,5 +145,10 @@ namespace MediaBrowser.Controller.LiveTv return 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.cs index 29b23a551..74cf950d4 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.cs index 6fc985643..91edc06c1 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.cs index 4a807df7a..b18651a68 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs @@ -38,7 +38,8 @@ namespace MediaBrowser.Controller.MediaEncoding SubtitlePlaybackMode 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.MediaEncoding private 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.cs index d6dd7698e..a4badee47 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.cs index f0272b335..1f273a3ee 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -171,6 +171,17 @@ namespace MediaBrowser.Controller.Session 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> /// <param name="cancellationToken">The cancellation token.</param> diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index d8a2464d6..078d4d70f 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.cs index 7517cea50..31f1e0a88 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -393,7 +393,7 @@ namespace MediaBrowser.Dlna throw 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.Dlna if (!string.Equals(path, current.Path, StringComparison.Ordinal) && current.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.cs index 1989c437a..202121f68 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToController.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToController.cs @@ -899,5 +899,11 @@ namespace MediaBrowser.Dlna.PlayTo return 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.cs index ecf5d72d5..4db4cd427 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -248,7 +248,7 @@ namespace MediaBrowser.MediaEncoding.Encoder protected 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.cs index 24b818f5a..10d8112ff 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -459,7 +459,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles try { _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.Subtitles try { _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.cs index e30cf1789..c4a9c5eea 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.Configuration public 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.cs index 9e33c1c36..aa49ee50d 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -7,12 +7,6 @@ namespace MediaBrowser.Model.Configuration 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> /// <value><c>true</c> if this instance is administrator; otherwise, <c>false</c>.</value> @@ -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.Configuration public 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.Configuration public 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.Configuration EnableLiveTvManagement = 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.Configuration IncludeTrailersInSuggestions = true; EnableCinemaMode = true; - EnableUserPreferenceAccess = true; - - AccessSchedules = new AccessSchedule[] { }; } } } diff --git a/MediaBrowser.Model/Connect/ConnectAuthorization.cs b/MediaBrowser.Model/Connect/ConnectAuthorization.cs index 0c545f4ba..9e4537d65 100644 --- a/MediaBrowser.Model/Connect/ConnectAuthorization.cs +++ b/MediaBrowser.Model/Connect/ConnectAuthorization.cs @@ -9,12 +9,12 @@ namespace MediaBrowser.Model.Connect public 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.cs index d40d353f0..77c574f8b 100644 --- a/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs +++ b/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs @@ -7,12 +7,12 @@ namespace MediaBrowser.Model.Connect public 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.cs index 0a6a37696..12b8c4071 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -52,6 +52,9 @@ namespace MediaBrowser.Model.Users public 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.Users BlockedMediaFolders = 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.cs index 700bca0fa..6175587a7 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -183,7 +183,7 @@ namespace MediaBrowser.Providers.Manager currentFile.Attributes &= ~FileAttributes.Hidden; } - currentFile.Delete(); + _fileSystem.DeleteFile(currentFile.FullName); } } finally diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index 0d318c377..66b0f9259 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -349,7 +349,7 @@ namespace MediaBrowser.Providers.Manager currentFile.Attributes &= ~FileAttributes.Hidden; } - currentFile.Delete(); + _fileSystem.DeleteFile(currentFile.FullName); deleted = true; } } diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 9a16ae24d..187f8814b 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -245,7 +245,7 @@ namespace MediaBrowser.Providers.Subtitles try { - File.Delete(path); + _fileSystem.DeleteFile(path); } finally { diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index 20dc6c485..fa49afbe9 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.cs index 7179395b4..0e0e4fbcb 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelDownloadScheduledTask.cs @@ -96,7 +96,7 @@ namespace MediaBrowser.Server.Implementations.Channels public 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.cs index c12a1161b..1130a510c 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.Channels try { - File.Delete(response.TempFilePath); + _fileSystem.DeleteFile(response.TempFilePath); } catch { diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 9fee27db9..05efcaa1c 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.cs index 67d844543..b703b204e 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -548,7 +548,7 @@ namespace MediaBrowser.Server.Implementations.Connect ImageUrl = 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.cs index d587e5af7..70a04d249 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.Devices private 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.cs index 1eb4a6655..bc1025305 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.EntryPoints void 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.cs index c31f46215..ccd427a47 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.cs index 611f887ee..cfc3e2b23 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -209,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization try { - 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.cs index 7c5269678..a6116ab09 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.cs index cf120f147..e3c8e6d25 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.cs index 226d97b3c..2c8413f5e 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.SocketSharp return (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 Helpers diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 597dcd9af..cceccceac 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -401,11 +401,11 @@ namespace MediaBrowser.Server.Implementations.Library try { - Directory.Delete(metadataPath, true); + _fileSystem.DeleteDirectory(metadataPath, true); } catch (DirectoryNotFoundException) { - + } catch (Exception ex) { @@ -420,12 +420,12 @@ namespace MediaBrowser.Server.Implementations.Library if (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); } } @@ -841,13 +841,30 @@ namespace MediaBrowser.Server.Implementations.Library } /// <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> /// <param name="name">The name.</param> /// <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.Library public 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.cs index 3b6de5998..b51a9ee7c 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.Library private 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.Library foreach (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.Library try { - 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.Library var 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.Library var 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.json index 943daff5e..8acce7b72 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.json index e3add2f19..7bd42507d 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.cs index a0b604645..56557d6e1 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -215,7 +215,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder try { - File.Delete(image); + _fileSystem.DeleteFile(image); } catch (IOException ex) { diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs index d9973afe7..8a04f29a2 100644 --- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs +++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs @@ -198,19 +198,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> /// <value>The game genre path.</value> diff --git a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs b/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs index 4a64d3753..4d5c40853 100644 --- a/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs +++ b/MediaBrowser.Server.Implementations/Session/HttpSessionController.cs @@ -209,6 +209,12 @@ namespace MediaBrowser.Server.Implementations.Session return 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 nvc diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index d9ec9b7e4..8bf39fd6b 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1632,5 +1632,26 @@ namespace MediaBrowser.Server.Implementations.Session return 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 file diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 7d1057397..19aaaf8a5 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Session public 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.Session public 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.Session public 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.Session public 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.Session public 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.Session public 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.Session public 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.Session return 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.cs index b8f199e6b..33db54ee1 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.Sync private 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.cs index c2925551b..068261ffd 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Implementations.Sync public bool IsHidden { - get { return true; } + get { return false; } } public bool IsEnabled diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 013e9205a..654539870 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.Common SyncRepository = 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.Common TVSeriesManager = 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.Common ConnectManager = 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.cs index 229fee18d..58e8e2da8 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.cs index 8fe841ffc..166c2627f 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.Migrations public 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.cs index ce4665b26..afdd4e623 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.Migrations public 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.cs index 5e3df5701..cb566d6cf 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.Migrations public 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.Migrations foreach (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.cs index adc8eecb1..7532a2edd 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.cs index 0262f711e..593bb7955 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.Native else { //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.cs index 45070e6ec..476fb58b9 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.Native public 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.cs index 6e3439079..74496ef9c 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -275,11 +275,11 @@ namespace MediaBrowser.WebDashboard.Api try { - Directory.Delete(path, true); + _fileSystem.DeleteDirectory(path, true); } catch (IOException) { - + } var creator = GetPackageCreator(); diff --git a/SharedVersion.cs b/SharedVersion.cs index 238d57f0c..5af3efc1c 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")] |
