From e8f6a6113150be0e961b0eadd44d431ab5ac07af Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Fri, 25 Jan 2019 22:51:34 +0100 Subject: [PATCH 01/27] Fix empty statement in DidlBuilder.cs --- Emby.Dlna/Didl/DidlBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 81c4d3d16c..34ad3f8fb4 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -932,7 +932,7 @@ namespace Emby.Dlna.Didl private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlWriter writer) { - ImageDownloadInfo imageInfo = GetImageInfo(item);; + ImageDownloadInfo imageInfo = GetImageInfo(item); if (imageInfo == null) { From ded9dee22c38e443a237d738bef97bd6d4442324 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 25 Jan 2019 23:05:01 +0100 Subject: [PATCH 02/27] Remove more compile time warnings --- .../Activity/ActivityLogEntryPoint.cs | 1 - .../ApplicationHost.cs | 3 +-- MediaBrowser.Api/PluginService.cs | 26 ++++++------------- .../UserLibrary/PlaystateService.cs | 10 +++---- .../Subtitles/ISubtitleManager.cs | 5 ---- .../Subtitles/SubtitleManager.cs | 9 ------- 6 files changed, 14 insertions(+), 40 deletions(-) diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index aef72c6972..d6a7c8b371 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -502,7 +502,6 @@ namespace Emby.Server.Implementations.Activity _sessionManager.PlaybackStart -= _sessionManager_PlaybackStart; _sessionManager.PlaybackStopped -= _sessionManager_PlaybackStopped; - _subManager.SubtitlesDownloaded -= _subManager_SubtitlesDownloaded; _subManager.SubtitleDownloadFailure -= _subManager_SubtitleDownloadFailure; _userManager.UserCreated -= _userManager_UserCreated; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index f5a4f15817..07e3368fed 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -112,7 +112,6 @@ using ServiceStack; using ServiceStack.Text.Jsv; using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions; using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate; -using UtfUnknown; namespace Emby.Server.Implementations { @@ -888,7 +887,7 @@ namespace Emby.Server.Implementations MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder); RegisterSingleInstance(MediaSourceManager); - SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager); + SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager); RegisterSingleInstance(SubtitleManager); ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LoggerFactory, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer); diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 94be454744..af61887b20 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -153,7 +153,11 @@ namespace MediaBrowser.Api private readonly INetworkManager _network; private readonly IDeviceManager _deviceManager; - public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, IInstallationManager installationManager, INetworkManager network, IDeviceManager deviceManager) + public PluginService(IJsonSerializer jsonSerializer, + IApplicationHost appHost, + IInstallationManager installationManager, + INetworkManager network, + IDeviceManager deviceManager) : base() { if (jsonSerializer == null) @@ -173,7 +177,7 @@ namespace MediaBrowser.Api /// /// The request. /// System.Object. - public async Task Get(GetRegistrationStatus request) + public object Get(GetRegistrationStatus request) { var record = new MBRegistrationRecord { @@ -187,26 +191,12 @@ namespace MediaBrowser.Api return ToOptimizedResult(record); } - //TODO this function is only kept for compatibility and should be removed once paid plugins break - public async Task Get(GetRegistration request) - { - var info = new RegistrationInfo - { - ExpirationDate = DateTime.Now.AddYears(100), - IsRegistered = true, - IsTrial = false, - Name = request.Name - }; - - return ToOptimizedResult(info); - } - /// /// Gets the specified request. /// /// The request. /// System.Object. - public async Task Get(GetPlugins request) + public object Get(GetPlugins request) { var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToArray(); return ToOptimizedResult(result); @@ -230,7 +220,7 @@ namespace MediaBrowser.Api /// /// The request. /// System.Object. - public async Task Get(GetPluginSecurityInfo request) + public object Get(GetPluginSecurityInfo request) { var result = new PluginSecurityInfo { diff --git a/MediaBrowser.Api/UserLibrary/PlaystateService.cs b/MediaBrowser.Api/UserLibrary/PlaystateService.cs index 76f91e3738..72a9430921 100644 --- a/MediaBrowser.Api/UserLibrary/PlaystateService.cs +++ b/MediaBrowser.Api/UserLibrary/PlaystateService.cs @@ -267,13 +267,13 @@ namespace MediaBrowser.Api.UserLibrary var session = GetSession(_sessionContext); - var dto = await UpdatePlayedStatus(user, request.Id, true, datePlayed).ConfigureAwait(false); + var dto = UpdatePlayedStatus(user, request.Id, true, datePlayed); foreach (var additionalUserInfo in session.AdditionalUsers) { var additionalUser = _userManager.GetUserById(additionalUserInfo.UserId); - await UpdatePlayedStatus(additionalUser, request.Id, true, datePlayed).ConfigureAwait(false); + UpdatePlayedStatus(additionalUser, request.Id, true, datePlayed); } return dto; @@ -412,13 +412,13 @@ namespace MediaBrowser.Api.UserLibrary var session = GetSession(_sessionContext); - var dto = await UpdatePlayedStatus(user, request.Id, false, null).ConfigureAwait(false); + var dto = UpdatePlayedStatus(user, request.Id, false, null); foreach (var additionalUserInfo in session.AdditionalUsers) { var additionalUser = _userManager.GetUserById(additionalUserInfo.UserId); - await UpdatePlayedStatus(additionalUser, request.Id, false, null).ConfigureAwait(false); + UpdatePlayedStatus(additionalUser, request.Id, false, null); } return dto; @@ -432,7 +432,7 @@ namespace MediaBrowser.Api.UserLibrary /// if set to true [was played]. /// The date played. /// Task. - private async Task UpdatePlayedStatus(User user, string itemId, bool wasPlayed, DateTime? datePlayed) + private UserItemDataDto UpdatePlayedStatus(User user, string itemId, bool wasPlayed, DateTime? datePlayed) { var item = _libraryManager.GetItemById(itemId); diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs index 2ee58bbe6a..0872335c55 100644 --- a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs +++ b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs @@ -15,11 +15,6 @@ namespace MediaBrowser.Controller.Subtitles /// event EventHandler SubtitleDownloadFailure; - /// - /// Occurs when [subtitles downloaded]. - /// - event EventHandler SubtitlesDownloaded; - /// /// Adds the parts. /// diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 468ba730ab..57e827061a 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -30,9 +30,7 @@ namespace MediaBrowser.Providers.Subtitles private readonly IFileSystem _fileSystem; private readonly ILibraryMonitor _monitor; private readonly IMediaSourceManager _mediaSourceManager; - private readonly IServerConfigurationManager _config; - public event EventHandler SubtitlesDownloaded; public event EventHandler SubtitleDownloadFailure; private ILocalizationManager _localization; @@ -42,14 +40,12 @@ namespace MediaBrowser.Providers.Subtitles IFileSystem fileSystem, ILibraryMonitor monitor, IMediaSourceManager mediaSourceManager, - IServerConfigurationManager config, ILocalizationManager localizationManager) { _logger = loggerFactory.CreateLogger(nameof(SubtitleManager)); _fileSystem = fileSystem; _monitor = monitor; _mediaSourceManager = mediaSourceManager; - _config = config; _localization = localizationManager; } @@ -134,11 +130,6 @@ namespace MediaBrowser.Providers.Subtitles return results.SelectMany(i => i).ToArray(); } - private SubtitleOptions GetOptions() - { - return _config.GetConfiguration("subtitles"); - } - public Task DownloadSubtitles(Video video, string subtitleId, CancellationToken cancellationToken) { var libraryOptions = BaseItem.LibraryManager.GetLibraryOptions(video); From cc3422b96b514621300f6ed419ce8cb8f8622073 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 26 Jan 2019 21:16:43 -0500 Subject: [PATCH 03/27] Use ffmpeg from jrottenberg/ffmpeg Eventually would like to move to his 4.0-vaapi image --- Dockerfile | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f727b4b4c..c79d6f8ee1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,5 @@ ARG DOTNET_VERSION=2 - -# Download ffmpeg first to allow quicker rebuild of other layers -FROM alpine as ffmpeg -ARG FFMPEG_URL=https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.0.3-64bit-static.tar.xz -RUN wget ${FFMPEG_URL} -O - | tar Jxf - \ - && mkdir ffmpeg-bin \ - && mv ffmpeg*/ffmpeg ffmpeg-bin \ - && mv ffmpeg*/ffprobe ffmpeg-bin - - FROM microsoft/dotnet:${DOTNET_VERSION}-sdk as builder WORKDIR /repo COPY . . @@ -20,7 +10,7 @@ RUN export DOTNET_CLI_TELEMETRY_OPTOUT=1 \ --output /jellyfin \ Jellyfin.Server - +FROM jrottenberg/ffmpeg:4.0-scratch as ffmpeg FROM microsoft/dotnet:${DOTNET_VERSION}-runtime # libfontconfig1 is required for Skia RUN apt-get update \ @@ -29,8 +19,8 @@ RUN apt-get update \ && apt-get clean autoclean \ && apt-get autoremove \ && rm -rf /var/lib/{apt,dpkg,cache,log} +COPY --from=ffmpeg / / COPY --from=builder /jellyfin /jellyfin -COPY --from=ffmpeg /ffmpeg-bin/* /usr/bin/ EXPOSE 8096 VOLUME /config /media ENTRYPOINT dotnet /jellyfin/jellyfin.dll -programdata /config From 42e0b32c7d601241f1451e1e7bd132b07decbf04 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 27 Jan 2019 16:08:51 +0100 Subject: [PATCH 04/27] Added AssemblyInfo for Jellyfin.Drawing.Skia --- .../Properties/AssemblyInfo.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Jellyfin.Drawing.Skia/Properties/AssemblyInfo.cs diff --git a/Jellyfin.Drawing.Skia/Properties/AssemblyInfo.cs b/Jellyfin.Drawing.Skia/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..ea1c457f6c --- /dev/null +++ b/Jellyfin.Drawing.Skia/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Jellyfin.Drawing.Skia")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Jellyfin Project")] +[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")] +[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] From 1a3543e5a5984d4ec5284f43b7df63a9d19c8a9c Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 27 Jan 2019 16:16:37 +0100 Subject: [PATCH 05/27] Remove code for pre-installed plugins --- .../ApplicationHost.cs | 75 +------------------ 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index f0a9149220..60cc19db70 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1564,7 +1564,7 @@ namespace Emby.Server.Implementations /// IEnumerable{Assembly}. protected List> GetComposablePartAssemblies() { - var list = GetPluginAssemblies(); + var list = GetPluginAssemblies(ApplicationPaths.PluginsPath); // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that // This will prevent the .dll file from getting locked, and allow us to replace it when needed @@ -1615,79 +1615,6 @@ namespace Emby.Server.Implementations protected abstract IEnumerable GetAssembliesWithPartsInternal(); - /// - /// Gets the plugin assemblies. - /// - /// IEnumerable{Assembly}. - private List> GetPluginAssemblies() - { - // Copy pre-installed plugins - var sourcePath = Path.Combine(ApplicationPaths.ApplicationResourcesPath, "plugins"); - CopyPlugins(sourcePath, ApplicationPaths.PluginsPath); - - return GetPluginAssemblies(ApplicationPaths.PluginsPath); - } - - private void CopyPlugins(string source, string target) - { - List files; - - try - { - files = Directory.EnumerateFiles(source, "*.dll", SearchOption.TopDirectoryOnly) - .ToList(); - - } - catch (DirectoryNotFoundException) - { - return; - } - - if (files.Count == 0) - { - return; - } - - foreach (var sourceFile in files) - { - var filename = Path.GetFileName(sourceFile); - var targetFile = Path.Combine(target, filename); - - var targetFileExists = File.Exists(targetFile); - - if (!targetFileExists && ServerConfigurationManager.Configuration.UninstalledPlugins.Contains(filename, StringComparer.OrdinalIgnoreCase)) - { - continue; - } - - if (targetFileExists && GetDllVersion(targetFile) >= GetDllVersion(sourceFile)) - { - continue; - } - - Directory.CreateDirectory(target); - File.Copy(sourceFile, targetFile, true); - } - } - - private Version GetDllVersion(string path) - { - try - { - var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion); - - Logger.LogInformation("File {Path} has version {Version}", path, result); - - return result; - } - catch (Exception ex) - { - Logger.LogError(ex, "Error getting version number from {Path}", path); - - return new Version(1, 0); - } - } - private List> GetPluginAssemblies(string path) { try From a4055779f6c824cc0289dfb4f77dc094f2de850a Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 27 Jan 2019 16:27:18 +0100 Subject: [PATCH 06/27] Change multi version logic for movies --- Emby.Naming/Video/VideoListResolver.cs | 65 ++++---------------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 0506d0734c..156739c0a7 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -175,71 +175,22 @@ namespace Emby.Naming.Video return videos; } - var list = new List(); - var folderName = Path.GetFileName(Path.GetDirectoryName(videos[0].Files[0].Path)); if (!string.IsNullOrEmpty(folderName) && folderName.Length > 1) { - if (videos.All(i => i.Files.Count == 1 && IsEligibleForMultiVersion(folderName, i.Files[0].Path))) - { - // Enforce the multi-version limit - if (videos.Count <= 8 && HaveSameYear(videos)) - { - var ordered = videos.OrderBy(i => i.Name).ToList(); - - list.Add(ordered[0]); - - list[0].AlternateVersions = ordered.Skip(1).Select(i => i.Files[0]).ToList(); - list[0].Name = folderName; - list[0].Extras.AddRange(ordered.Skip(1).SelectMany(i => i.Extras)); + var ordered = videos.OrderBy(i => i.Name).ToList(); - return list; - } - } + return ordered.GroupBy(v => new {v.Name, v.Year}).Select(group => new VideoInfo + { + Name = folderName, + Files = group.First().Files, + AlternateVersions = group.Skip(1).Select(i => i.Files[0]).ToList(), + Extras = group.First().Extras.Concat(group.Skip(1).SelectMany(i => i.Extras)).ToList() + }); } return videos; - //foreach (var video in videos.OrderBy(i => i.Name)) - //{ - // var match = list - // .FirstOrDefault(i => string.Equals(i.Name, video.Name, StringComparison.OrdinalIgnoreCase)); - - // if (match != null && video.Files.Count == 1 && match.Files.Count == 1) - // { - // match.AlternateVersions.Add(video.Files[0]); - // match.Extras.AddRange(video.Extras); - // } - // else - // { - // list.Add(video); - // } - //} - - //return list; - } - - private bool HaveSameYear(List videos) - { - return videos.Select(i => i.Year ?? -1).Distinct().Count() < 2; - } - - private bool IsEligibleForMultiVersion(string folderName, string testFilename) - { - testFilename = Path.GetFileNameWithoutExtension(testFilename); - - if (string.Equals(folderName, testFilename, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase)) - { - testFilename = testFilename.Substring(folderName.Length).Trim(); - return testFilename.StartsWith("-", StringComparison.OrdinalIgnoreCase) || Regex.Replace(testFilename, @"\[([^]]*)\]", "").Trim() == string.Empty; - } - - return false; } private List GetExtras(IEnumerable remainingFiles, List baseNames) From 42abb5a9931806a2ae1cedd433144ebf82768a0d Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 27 Jan 2019 16:37:12 +0100 Subject: [PATCH 07/27] Remove unnecessary ToList --- Emby.Naming/Video/VideoListResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 156739c0a7..db8ebb56a9 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -179,7 +179,7 @@ namespace Emby.Naming.Video if (!string.IsNullOrEmpty(folderName) && folderName.Length > 1) { - var ordered = videos.OrderBy(i => i.Name).ToList(); + var ordered = videos.OrderBy(i => i.Name); return ordered.GroupBy(v => new {v.Name, v.Year}).Select(group => new VideoInfo { From 05ad2e9b3f5209d9e7ff9949d8c20cd8ef7062b6 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 27 Jan 2019 16:50:17 +0100 Subject: [PATCH 08/27] Add Year to the new VideoInfo --- Emby.Naming/Video/VideoListResolver.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index db8ebb56a9..ef97b87396 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -184,6 +184,7 @@ namespace Emby.Naming.Video return ordered.GroupBy(v => new {v.Name, v.Year}).Select(group => new VideoInfo { Name = folderName, + Year = group.First().Year, Files = group.First().Files, AlternateVersions = group.Skip(1).Select(i => i.Files[0]).ToList(), Extras = group.First().Extras.Concat(group.Skip(1).SelectMany(i => i.Extras)).ToList() From ffe79c89829fb232e8ccb4ae4caf4b732ce51600 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 27 Jan 2019 17:00:17 +0100 Subject: [PATCH 09/27] Check if file exists instead of catching exceptions --- .../AppBase/BaseConfigurationManager.cs | 9 ++-- .../HttpClientManager/HttpClientManager.cs | 30 ++++-------- .../Library/LibraryManager.cs | 47 +++++++++---------- .../Library/UserManager.cs | 18 +++---- .../ScheduledTasks/ChapterImagesTask.cs | 21 +++++---- .../ScheduledTasks/ScheduledTaskWorker.cs | 47 ++++++------------- 6 files changed, 73 insertions(+), 99 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 59c7c655f1..9740f5ee30 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -246,13 +246,14 @@ namespace Emby.Server.Implementations.AppBase private object LoadConfiguration(string path, Type configurationType) { - try + if (!File.Exists(path)) { - return XmlSerializer.DeserializeFromFile(configurationType, path); + return Activator.CreateInstance(configurationType); } - catch (FileNotFoundException) + + try { - return Activator.CreateInstance(configurationType); + return XmlSerializer.DeserializeFromFile(configurationType, path); } catch (IOException) { diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index ea620cb2ee..217f366e03 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -286,28 +286,18 @@ namespace Emby.Server.Implementations.HttpClientManager private HttpResponseInfo GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url) { - try - { - if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow) - { - var stream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true); - - return new HttpResponseInfo - { - ResponseUrl = url, - Content = stream, - StatusCode = HttpStatusCode.OK, - ContentLength = stream.Length - }; - } - } - catch (FileNotFoundException) // REVIEW: @bond Is this really faster? - { - - } - catch (DirectoryNotFoundException) + if (File.Exists(responseCachePath) + && _fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow) { + var stream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true); + return new HttpResponseInfo + { + ResponseUrl = url, + Content = stream, + StatusCode = HttpStatusCode.OK, + ContentLength = stream.Length + }; } return null; diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index ad070ed794..9688ab385a 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -395,38 +395,33 @@ namespace Emby.Server.Implementations.Library foreach (var fileSystemInfo in item.GetDeletePaths().ToList()) { - try + if (File.Exists(fileSystemInfo.FullName)) { - _logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName); - if (fileSystemInfo.IsDirectory) + try { - _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true); + _logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName); + if (fileSystemInfo.IsDirectory) + { + _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true); + } + else + { + _fileSystem.DeleteFile(fileSystemInfo.FullName); + } } - else + catch (IOException) { - _fileSystem.DeleteFile(fileSystemInfo.FullName); + if (isRequiredForDelete) + { + throw; + } } - } - catch (FileNotFoundException) - { - // may have already been deleted manually by user - } - catch (DirectoryNotFoundException) - { - // may have already been deleted manually by user - } - catch (IOException) - { - if (isRequiredForDelete) - { - throw; - } - } - catch (UnauthorizedAccessException) - { - if (isRequiredForDelete) + catch (UnauthorizedAccessException) { - throw; + if (isRequiredForDelete) + { + throw; + } } } diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 6139659b70..d6f8446504 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -1029,6 +1029,11 @@ namespace Emby.Server.Implementations.Library { var path = GetPolicyFilePath(user); + if (!File.Exists(path)) + { + return GetDefaultPolicy(user); + } + try { lock (_policySyncLock) @@ -1036,10 +1041,6 @@ namespace Emby.Server.Implementations.Library return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path); } } - catch (FileNotFoundException) - { - return GetDefaultPolicy(user); - } catch (IOException) { return GetDefaultPolicy(user); @@ -1128,6 +1129,11 @@ namespace Emby.Server.Implementations.Library { var path = GetConfigurationFilePath(user); + if (!File.Exists(path)) + { + return new UserConfiguration(); + } + try { lock (_configSyncLock) @@ -1135,10 +1141,6 @@ namespace Emby.Server.Implementations.Library return (UserConfiguration)_xmlSerializer.DeserializeFromFile(typeof(UserConfiguration), path); } } - catch (FileNotFoundException) - { - return new UserConfiguration(); - } catch (IOException) { return new UserConfiguration(); diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index 0ae7ae96cf..57bc61c7a2 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -101,17 +101,20 @@ namespace Emby.Server.Implementations.ScheduledTasks List previouslyFailedImages; - try + if (File.Exists(failHistoryPath)) { - previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath) - .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) - .ToList(); - } - catch (FileNotFoundException) - { - previouslyFailedImages = new List(); + try + { + previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath) + .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) + .ToList(); + } + catch (IOException) + { + previouslyFailedImages = new List(); + } } - catch (IOException) + else { previouslyFailedImages = new List(); } diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 93a9a0d814..88b3dd07f0 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -129,21 +129,16 @@ namespace Emby.Server.Implementations.ScheduledTasks { if (_lastExecutionResult == null && !_readFromFile) { - try + if (File.Exists(path)) { - _lastExecutionResult = JsonSerializer.DeserializeFromFile(path); - } - catch (DirectoryNotFoundException) - { - // File doesn't exist. No biggie - } - catch (FileNotFoundException) - { - // File doesn't exist. No biggie - } - catch (Exception ex) - { - Logger.LogError(ex, "Error deserializing {path}", path); + try + { + _lastExecutionResult = JsonSerializer.DeserializeFromFile(path); + } + catch (Exception ex) + { + Logger.LogError(ex, "Error deserializing {File}", path); + } } _readFromFile = true; } @@ -532,28 +527,16 @@ namespace Emby.Server.Implementations.ScheduledTasks private TaskTriggerInfo[] LoadTriggerSettings() { - try - { - var list = JsonSerializer.DeserializeFromFile>(GetConfigurationFilePath()); - - if (list != null) - { - return list.ToArray(); - } - } - catch (FileNotFoundException) - { - // File doesn't exist. No biggie. Return defaults. - } - catch (DirectoryNotFoundException) + string path = GetConfigurationFilePath(); + if (!File.Exists(path)) { // File doesn't exist. No biggie. Return defaults. + GetDefaultTriggers(); } - catch - { - } - return GetDefaultTriggers(); + var list = JsonSerializer.DeserializeFromFile(path); + + return list ?? GetDefaultTriggers(); } private TaskTriggerInfo[] GetDefaultTriggers() From cc598a86f1025ac98e8c6dc5792a3292233e462d Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 27 Jan 2019 16:14:54 +0100 Subject: [PATCH 10/27] Make guidance in PR template comments, this way we don't get so people just leaving it there. --- .github/pull_request_template.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b2b3cf241e..967be0fb73 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,9 +1,11 @@ + **Changes** -Describe your changes here in 1-5 sentences. + **Issues** -Tag any issues that this PR solves here. -Fixes # + From 39195aae09917aeb0bb150800cc81e1a79db1938 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 27 Jan 2019 16:16:45 +0100 Subject: [PATCH 11/27] Make guidance in issue templates comments, this will declutter issues when people do not remove it. --- .github/ISSUE_TEMPLATE/bug_report.md | 12 ++++++------ .github/ISSUE_TEMPLATE/enhancement-request.md | 8 ++++---- .github/ISSUE_TEMPLATE/feature_request.md | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4abd39cfc5..137a689e8b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,23 +8,23 @@ assignees: '' --- **Describe the bug** -A clear and concise description of what the bug is. + **To Reproduce** -Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error **Expected behavior** -A clear and concise description of what you expected to happen. + **Logs** -Please paste any log errors. + **Screenshots** -If applicable, add screenshots to help explain your problem. + **System (please complete the following information):** - OS: [e.g. Docker, Debian, Windows] @@ -32,4 +32,4 @@ If applicable, add screenshots to help explain your problem. - Jellyfin Version: [e.g. 10.0.1] **Additional context** -Add any other context about the problem here. + diff --git a/.github/ISSUE_TEMPLATE/enhancement-request.md b/.github/ISSUE_TEMPLATE/enhancement-request.md index 57c0d4cae2..a655b60f53 100644 --- a/.github/ISSUE_TEMPLATE/enhancement-request.md +++ b/.github/ISSUE_TEMPLATE/enhancement-request.md @@ -8,13 +8,13 @@ assignees: '' --- **Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + **Describe the solution you'd like** -A clear and concise description of what you want to happen. + **Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. + **Additional context** -Add any other context or screenshots about the feature request here. + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index a2ce072452..3cbc8cbb91 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -8,7 +8,7 @@ assignees: '' --- **Describe the feature you'd like** -A clear and concise description of what you want to happen. + **Additional context** -Add any other context or screenshots about the feature request here. + From a05d803d4c188e3bc6ae22e5be907f74eec271bf Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 27 Jan 2019 20:18:51 +0100 Subject: [PATCH 12/27] Fix crash when trying to deserialize a non-existing scheduled task --- .../ScheduledTasks/ScheduledTaskWorker.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 88b3dd07f0..5fa24e6470 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -528,14 +528,13 @@ namespace Emby.Server.Implementations.ScheduledTasks private TaskTriggerInfo[] LoadTriggerSettings() { string path = GetConfigurationFilePath(); - if (!File.Exists(path)) + TaskTriggerInfo[] list = null; + if (File.Exists(path)) { - // File doesn't exist. No biggie. Return defaults. - GetDefaultTriggers(); + list = JsonSerializer.DeserializeFromFile(path); } - var list = JsonSerializer.DeserializeFromFile(path); - + // Return defaults if file doesn't exist. return list ?? GetDefaultTriggers(); } From dc68d61491a21154e9f56a33b399d13b046ff1ac Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Mon, 28 Jan 2019 21:55:44 +0100 Subject: [PATCH 13/27] Fix default aspect ratio --- MediaBrowser.Controller/Drawing/ImageHelper.cs | 3 ++- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/Drawing/ImageHelper.cs b/MediaBrowser.Controller/Drawing/ImageHelper.cs index f88a632236..432cf80423 100644 --- a/MediaBrowser.Controller/Drawing/ImageHelper.cs +++ b/MediaBrowser.Controller/Drawing/ImageHelper.cs @@ -63,7 +63,8 @@ namespace MediaBrowser.Controller.Drawing case ImageType.Logo: return 2.58; case ImageType.Primary: - return item.GetDefaultPrimaryImageAspectRatio(); + double defaultPrimaryImageAspectRatio = item.GetDefaultPrimaryImageAspectRatio(); + return defaultPrimaryImageAspectRatio > 0 ? defaultPrimaryImageAspectRatio : 2.0 / 3; default: return 1; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 846fd9eec4..0d1a0ce86d 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1518,7 +1518,7 @@ namespace MediaBrowser.Controller.Entities public virtual double GetDefaultPrimaryImageAspectRatio() { - return 2.0 / 3; + return 0; } public virtual string CreatePresentationUniqueKey() From 3a831994f69bbde699a1a725b57d8fd1d7e98641 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 21:47:11 +0100 Subject: [PATCH 14/27] Unwrapped GetDirectoryName and DirectorySeperatorChar --- BDInfo/BDROM.cs | 4 ++-- Emby.Drawing/ImageProcessor.cs | 2 +- Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs | 4 ++-- .../AppBase/BaseConfigurationManager.cs | 4 ++-- .../AppBase/ConfigurationHelper.cs | 2 +- .../Channels/ChannelManager.cs | 4 ++-- Emby.Server.Implementations/Devices/DeviceId.cs | 2 +- .../Devices/DeviceManager.cs | 6 +++--- Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs | 4 ++-- .../HttpClientManager/HttpClientManager.cs | 2 +- Emby.Server.Implementations/IO/FileRefresher.cs | 2 +- Emby.Server.Implementations/IO/LibraryMonitor.cs | 6 +++--- .../Images/BaseDynamicImageProvider.cs | 4 ++-- .../Library/CoreResolutionIgnoreRule.cs | 3 ++- .../Library/LibraryManager.cs | 4 ++-- .../Library/MediaSourceManager.cs | 2 +- .../Library/Resolvers/PhotoResolver.cs | 2 +- Emby.Server.Implementations/Library/UserManager.cs | 4 ++-- .../LiveTv/EmbyTV/DirectRecorder.cs | 5 +++-- .../LiveTv/EmbyTV/EmbyTV.cs | 14 +++++++------- .../LiveTv/EmbyTV/EncodedRecorder.cs | 4 ++-- .../LiveTv/EmbyTV/ItemDataProvider.cs | 2 +- .../LiveTv/Listings/XmlTvListingsProvider.cs | 2 +- .../LiveTv/TunerHosts/BaseTunerHost.cs | 2 +- .../TunerHosts/HdHomerun/HdHomerunUdpStream.cs | 2 +- .../LiveTv/TunerHosts/SharedHttpStream.cs | 3 ++- .../Localization/LocalizationManager.cs | 2 +- .../MediaEncoder/EncodingManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 2 +- Emby.Server.Implementations/ResourceFileManager.cs | 4 ++-- .../ScheduledTasks/ChapterImagesTask.cs | 2 +- .../ScheduledTasks/ScheduledTaskWorker.cs | 4 ++-- .../Updates/InstallationManager.cs | 4 ++-- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 6 +++--- MediaBrowser.Api/ApiEntryPoint.cs | 2 +- MediaBrowser.Api/EnvironmentService.cs | 2 +- MediaBrowser.Api/Images/ImageByNameService.cs | 2 +- MediaBrowser.Api/Images/RemoteImageService.cs | 4 ++-- MediaBrowser.Api/ItemLookupService.cs | 4 ++-- MediaBrowser.Api/Playback/BaseStreamingService.cs | 4 ++-- MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 2 +- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 6 +++--- MediaBrowser.Controller/Entities/BaseItem.cs | 6 +++--- MediaBrowser.Controller/Entities/Game.cs | 2 +- MediaBrowser.Controller/Entities/TV/Season.cs | 2 +- MediaBrowser.Controller/Entities/Video.cs | 2 +- MediaBrowser.Controller/Library/ItemResolveArgs.cs | 2 +- MediaBrowser.Controller/Playlists/Playlist.cs | 2 +- .../Images/EpisodeLocalImageProvider.cs | 3 ++- .../Providers/GameXmlProvider.cs | 2 +- MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 4 ++-- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 4 ++-- .../Subtitles/SubtitleEncoder.cs | 4 ++-- .../BoxSets/MovieDbBoxSetProvider.cs | 2 +- MediaBrowser.Providers/Manager/ImageSaver.cs | 10 +++++----- .../MediaInfo/AudioImageProvider.cs | 2 +- .../Movies/FanartMovieImageProvider.cs | 2 +- .../Movies/GenericMovieDbInfo.cs | 3 ++- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 2 +- .../Music/AudioDbAlbumProvider.cs | 2 +- .../Music/AudioDbArtistProvider.cs | 2 +- .../Music/FanArtArtistProvider.cs | 2 +- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 4 ++-- .../People/MovieDbPersonProvider.cs | 2 +- .../Studios/StudiosImageProvider.cs | 2 +- .../Subtitles/SubtitleManager.cs | 2 +- .../TV/FanArt/FanartSeriesProvider.cs | 2 +- .../TV/TheMovieDb/MovieDbProviderBase.cs | 2 +- .../TV/TheMovieDb/MovieDbSeasonProvider.cs | 2 +- .../TV/TheMovieDb/MovieDbSeriesProvider.cs | 4 ++-- .../TV/TheTVDB/TvdbEpisodeProvider.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs | 2 +- 73 files changed, 119 insertions(+), 114 deletions(-) diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index 4cd6360232..85ea7b5773 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -92,7 +92,7 @@ namespace BDInfo } DirectoryRoot = - _fileSystem.GetDirectoryInfo(_fileSystem.GetDirectoryName(DirectoryBDMV.FullName)); + _fileSystem.GetDirectoryInfo(Path.GetDirectoryName(DirectoryBDMV.FullName)); DirectoryBDJO = GetDirectory("BDJO", DirectoryBDMV, 0); DirectoryCLIPINF = @@ -345,7 +345,7 @@ namespace BDInfo { return dir; } - var parentFolder = _fileSystem.GetDirectoryName(dir.FullName); + var parentFolder = Path.GetDirectoryName(dir.FullName); if (string.IsNullOrEmpty(parentFolder)) { dir = null; diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 8ac2b9b275..ec50798aa9 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -631,7 +631,7 @@ namespace Emby.Drawing return (enhancedImagePath, treatmentRequiresTransparency); } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(enhancedImagePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, enhancedImagePath, item, imageType, imageIndex).ConfigureAwait(false); diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index ac486f1675..611e4263ca 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs @@ -39,7 +39,7 @@ namespace IsoMounter _logger = logger; ProcessFactory = processFactory; - MountPointRoot = FileSystem.DirectorySeparatorChar + "tmp" + FileSystem.DirectorySeparatorChar + "Emby"; + MountPointRoot = Path.DirectorySeparatorChar + "tmp" + Path.DirectorySeparatorChar + "Emby"; _logger.LogDebug( "[{0}] System PATH is currently set to [{1}].", @@ -216,7 +216,7 @@ namespace IsoMounter if (!string.IsNullOrEmpty(path) && FileSystem.FileExists(path = Path.Combine(path, name))) { - return FileSystem.GetFullPath(path); + return Path.GetFullPath(path); } } diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 9740f5ee30..312ef14c48 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.AppBase Logger.LogInformation("Saving system configuration"); var path = CommonApplicationPaths.SystemConfigurationFilePath; - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path)); + FileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_configurationSyncLock) { @@ -294,7 +294,7 @@ namespace Emby.Server.Implementations.AppBase _configurations.AddOrUpdate(key, configuration, (k, v) => configuration); var path = GetConfigurationFile(key); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path)); + FileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_configurationSyncLock) { diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index ee6da95fe1..5c386d3efb 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.AppBase // If the file didn't exist before, or if something has changed, re-save if (buffer == null || !buffer.SequenceEqual(newBytes)) { - fileSystem.CreateDirectory(fileSystem.GetDirectoryName(path)); + fileSystem.CreateDirectory(Path.GetDirectoryName(path)); // Save it after load in case we got new items fileSystem.WriteAllBytes(path, newBytes); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index a306b01699..3878928011 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -355,7 +355,7 @@ namespace Emby.Server.Implementations.Channels return; } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(mediaSources, path); } @@ -834,7 +834,7 @@ namespace Emby.Server.Implementations.Channels { try { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(result, path); } diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 00761809aa..6092428c8b 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Devices { var path = CachePath; - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_syncLock) { diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index 60d57519e6..b8521f9b2a 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Devices public void SaveCapabilities(string deviceId, ClientCapabilities capabilities) { var path = Path.Combine(GetDevicePath(deviceId), "capabilities.json"); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_capabilitiesSyncLock) { @@ -239,7 +239,7 @@ namespace Emby.Server.Implementations.Devices path = Path.Combine(path, file.Name); path = Path.ChangeExtension(path, MimeTypes.ToExtension(file.MimeType) ?? "jpg"); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); await EnsureLibraryFolder(uploadPathInfo.Item2, uploadPathInfo.Item3).ConfigureAwait(false); @@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Devices private void AddCameraUpload(string deviceId, LocalFileInfo file) { var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json"); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_cameraUploadSyncLock) { diff --git a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs index 9a4aec958c..63d1215d82 100644 --- a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs +++ b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs @@ -92,7 +92,7 @@ namespace Emby.Server.Implementations.FFMpeg else { info = existingVersion; - versionedDirectoryPath = _fileSystem.GetDirectoryName(info.EncoderPath); + versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath); excludeFromDeletions.Add(versionedDirectoryPath); } } @@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.FFMpeg { EncoderPath = encoder, ProbePath = probe, - Version = Path.GetFileName(_fileSystem.GetDirectoryName(probe)) + Version = Path.GetFileName(Path.GetDirectoryName(probe)) }; } } diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 217f366e03..a4902fc786 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -305,7 +305,7 @@ namespace Emby.Server.Implementations.HttpClientManager private async Task CacheResponse(HttpResponseInfo response, string responseCachePath) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(responseCachePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath)); using (var fileStream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true)) { diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 6bee178ea8..af0c0a6a6c 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -189,7 +189,7 @@ namespace Emby.Server.Implementations.IO { item = LibraryManager.FindByPath(path, null); - path = _fileSystem.GetDirectoryName(path); + path = System.IO.Path.GetDirectoryName(path); } if (item != null) diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 204f9d949f..45d8104f75 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -483,7 +483,7 @@ namespace Emby.Server.Implementations.IO } // Go up a level - var parent = _fileSystem.GetDirectoryName(i); + var parent = Path.GetDirectoryName(i); if (!string.IsNullOrEmpty(parent)) { if (_fileSystem.AreEqual(parent, path)) @@ -509,7 +509,7 @@ namespace Emby.Server.Implementations.IO private void CreateRefresher(string path) { - var parentPath = _fileSystem.GetDirectoryName(path); + var parentPath = Path.GetDirectoryName(path); lock (_activeRefreshers) { @@ -538,7 +538,7 @@ namespace Emby.Server.Implementations.IO } // They are siblings. Rebase the refresher to the parent folder. - if (string.Equals(parentPath, _fileSystem.GetDirectoryName(refresher.Path), StringComparison.Ordinal)) + if (string.Equals(parentPath, Path.GetDirectoryName(refresher.Path), StringComparison.Ordinal)) { refresher.ResetPath(parentPath, path); return; diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index b99b98157d..24152d3de7 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Images CancellationToken cancellationToken) { var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N")); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPathWithoutExtension)); + FileSystem.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension)); string outputPath = CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0); if (string.IsNullOrEmpty(outputPath)) @@ -165,7 +165,7 @@ namespace Emby.Server.Implementations.Images private string CreateCollage(BaseItem primaryItem, List items, string outputPath, int width, int height) { - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); var options = new ImageCollageOptions { diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index c0a126b84e..80f746c7a9 100644 --- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; @@ -146,7 +147,7 @@ namespace Emby.Server.Implementations.Library if (parent != null) { // Don't resolve these into audio files - if (string.Equals(_fileSystem.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && _libraryManager.IsAudioFile(filename)) + if (string.Equals(Path.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && _libraryManager.IsAudioFile(filename)) { return true; } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 9688ab385a..89881d730c 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1228,7 +1228,7 @@ namespace Emby.Server.Implementations.Library private string GetCollectionType(string path) { return _fileSystem.GetFilePaths(path, new[] { ".collection" }, true, false) - .Select(i => _fileSystem.GetFileNameWithoutExtension(i)) + .Select(i => Path.GetFileNameWithoutExtension(i)) .FirstOrDefault(i => !string.IsNullOrEmpty(i)); } @@ -2976,7 +2976,7 @@ namespace Emby.Server.Implementations.Library var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName); - var shortcutFilename = _fileSystem.GetFileNameWithoutExtension(path); + var shortcutFilename = Path.GetFileNameWithoutExtension(path); var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension); diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index 1ed838893e..17f69909f3 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -670,7 +670,7 @@ namespace Emby.Server.Implementations.Library if (cacheFilePath != null) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); _jsonSerializer.SerializeToFile(mediaInfo, cacheFilePath); //_logger.LogDebug("Saved media info to {0}", cacheFilePath); diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs index 78c1c6629f..9de766767f 100644 --- a/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs @@ -43,7 +43,7 @@ namespace Emby.Server.Implementations.Library.Resolvers var filename = Path.GetFileNameWithoutExtension(args.Path); // Make sure the image doesn't belong to a video file - var files = args.DirectoryService.GetFiles(_fileSystem.GetDirectoryName(args.Path)); + var files = args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)); var libraryOptions = args.GetLibraryOptions(); foreach (var file in files) diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index d6f8446504..04787add94 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -1080,7 +1080,7 @@ namespace Emby.Server.Implementations.Library var path = GetPolicyFilePath(user); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_policySyncLock) { @@ -1176,7 +1176,7 @@ namespace Emby.Server.Implementations.Library config = _jsonSerializer.DeserializeFromString(json); } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_configSyncLock) { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs index 7d7ef21e3a..950b0b3606 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; @@ -41,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private async Task RecordFromDirectStreamProvider(IDirectStreamProvider directStreamProvider, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(targetFile)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile)); using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { @@ -77,7 +78,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { _logger.LogInformation("Opened recording stream from tuner provider"); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(targetFile)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile)); using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 4805e54ddf..f28f8d7320 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1489,7 +1489,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { _logger.LogInformation("Triggering refresh on {path}", path); - var item = GetAffectedBaseItem(_fileSystem.GetDirectoryName(path)); + var item = GetAffectedBaseItem(Path.GetDirectoryName(path)); if (item != null) { @@ -1500,8 +1500,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV RefreshPaths = new string[] { path, - _fileSystem.GetDirectoryName(path), - _fileSystem.GetDirectoryName(_fileSystem.GetDirectoryName(path)) + Path.GetDirectoryName(path), + Path.GetDirectoryName(Path.GetDirectoryName(path)) } }, RefreshPriority.High); @@ -1512,13 +1512,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { BaseItem item = null; - var parentPath = _fileSystem.GetDirectoryName(path); + var parentPath = Path.GetDirectoryName(path); while (item == null && !string.IsNullOrEmpty(path)) { item = _libraryManager.FindByPath(path, null); - path = _fileSystem.GetDirectoryName(path); + path = Path.GetDirectoryName(path); } if (item != null) @@ -1676,7 +1676,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV while (FileExists(path, timerId)) { - var parent = _fileSystem.GetDirectoryName(originalPath); + var parent = Path.GetDirectoryName(originalPath); var name = Path.GetFileNameWithoutExtension(originalPath); name += " - " + index.ToString(CultureInfo.InvariantCulture); @@ -1822,7 +1822,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return; } - var imageSavePath = Path.Combine(_fileSystem.GetDirectoryName(recordingPath), imageSaveFilenameWithoutExtension); + var imageSavePath = Path.Combine(Path.GetDirectoryName(recordingPath), imageSaveFilenameWithoutExtension); // preserve original image extension imageSavePath = Path.ChangeExtension(imageSavePath, Path.GetExtension(image.Path)); diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index c11a85027d..ec65f90b91 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken) { _targetPath = targetFile; - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(targetFile)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile)); var process = _processFactory.Create(new ProcessOptions { @@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _logger.LogInformation(commandLineLogMessage); var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "record-transcode-" + Guid.NewGuid() + ".txt"); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(logFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. _logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 1b8287ed1b..d3972d9e0b 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } var file = _dataPath + ".json"; - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(file)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(file)); lock (_fileDataLock) { diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index e7a3d748d1..6e5d037f76 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -83,7 +83,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings }).ConfigureAwait(false); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFile)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFile)); _fileSystem.CopyFile(tempFile, cacheFile, true); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs index ee86f66e69..6a51cd98c9 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { try { - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(channelCacheFile)); + FileSystem.CreateDirectory(Path.GetDirectoryName(channelCacheFile)); JsonSerializer.SerializeToFile(channels, channelCacheFile); } catch (IOException) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs index 2542ddd2ad..045d8bb205 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var uri = new Uri(mediaSource.Path); var localPort = _networkManager.GetRandomUnusedUdpPort(); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(TempFilePath)); Logger.LogInformation("Opening HDHR UDP Live stream from {host}", uri.Host); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs index b39a9f6799..3c1cd9e7c2 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; @@ -35,7 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var url = mediaSource.Path; - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(TempFilePath)); var typeName = GetType().Name; Logger.LogInformation("Opening " + typeName + " Live stream from {0}", url); diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index c408a47f62..ce3d00f156 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -337,7 +337,7 @@ namespace Emby.Server.Implementations.Localization .Where(i => i != null) .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase); - var countryCode = _fileSystem.GetFileNameWithoutExtension(file) + var countryCode = Path.GetFileNameWithoutExtension(file) .Split('-') .Last(); diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 0575ff5536..09141567ee 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -141,7 +141,7 @@ namespace Emby.Server.Implementations.MediaEncoder var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, Array.Empty()); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); var container = video.Container; diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 17f4457080..d428a32223 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -455,7 +455,7 @@ namespace Emby.Server.Implementations.Playlists private string NormalizeItemPath(string playlistPath, string itemPath) { - return MakeRelativePath(_fileSystem.GetDirectoryName(playlistPath), itemPath); + return MakeRelativePath(Path.GetDirectoryName(playlistPath), itemPath); } private static string MakeRelativePath(string folderPath, string fileAbsolutePath) diff --git a/Emby.Server.Implementations/ResourceFileManager.cs b/Emby.Server.Implementations/ResourceFileManager.cs index 6acc7e1d19..8c1f765e27 100644 --- a/Emby.Server.Implementations/ResourceFileManager.cs +++ b/Emby.Server.Implementations/ResourceFileManager.cs @@ -42,11 +42,11 @@ namespace Emby.Server.Implementations private string GetResourcePath(string basePath, string virtualPath) { - var fullPath = Path.Combine(basePath, virtualPath.Replace('/', _fileSystem.DirectorySeparatorChar)); + var fullPath = Path.Combine(basePath, virtualPath.Replace('/', Path.DirectorySeparatorChar)); try { - fullPath = _fileSystem.GetFullPath(fullPath); + fullPath = Path.GetFullPath(fullPath); } catch (Exception ex) { diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index 57bc61c7a2..93926da3e2 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -139,7 +139,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { previouslyFailedImages.Add(key); - var parentPath = _fileSystem.GetDirectoryName(failHistoryPath); + var parentPath = Path.GetDirectoryName(failHistoryPath); _fileSystem.CreateDirectory(parentPath); diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 5fa24e6470..3c53b84abe 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.ScheduledTasks _lastExecutionResult = value; var path = GetHistoryFilePath(); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_lastExecutionResultSyncLock) { @@ -565,7 +565,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { var path = GetConfigurationFilePath(); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); JsonSerializer.SerializeToFile(triggers, path); } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 44377a897b..b9fd404af7 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -570,7 +570,7 @@ namespace Emby.Server.Implementations.Updates // Success - move it to the real target try { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(target)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(target)); _fileSystem.CopyFile(tempFile, target, true); //If it is an archive - write out a version file so we know what it is if (isArchive) @@ -611,7 +611,7 @@ namespace Emby.Server.Implementations.Updates _logger.LogInformation("Deleting plugin file {0}", path); // Make this case-insensitive to account for possible incorrect assembly naming - var file = _fileSystem.GetFilePaths(_fileSystem.GetDirectoryName(path)) + var file = _fileSystem.GetFilePaths(Path.GetDirectoryName(path)) .FirstOrDefault(i => string.Equals(i, path, StringComparison.OrdinalIgnoreCase)); if (!string.IsNullOrWhiteSpace(file)) diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index a06477d3eb..3261c970dd 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -219,7 +219,7 @@ namespace Jellyfin.Drawing.Skia var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + Path.GetExtension(path) ?? string.Empty); - fileSystem.CreateDirectory(fileSystem.GetDirectoryName(tempPath)); + fileSystem.CreateDirectory(Path.GetDirectoryName(tempPath)); fileSystem.CopyFile(path, tempPath, true); return tempPath; @@ -532,7 +532,7 @@ namespace Jellyfin.Drawing.Skia // If all we're doing is resizing then we can stop now if (!hasBackgroundColor && !hasForegroundColor && blur == 0 && !hasIndicator) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); using (var outputStream = new SKFileWStream(outputPath)) using (var pixmap = new SKPixmap(new SKImageInfo(width, height), resizedBitmap.GetPixels())) { @@ -584,7 +584,7 @@ namespace Jellyfin.Drawing.Skia DrawIndicator(canvas, width, height, options); } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); using (var outputStream = new SKFileWStream(outputPath)) { using (var pixmap = new SKPixmap(new SKImageInfo(width, height), saveBitmap.GetPixels())) diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 8ae0ad9428..763535129a 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -646,7 +646,7 @@ namespace MediaBrowser.Api /// The output file path. private void DeleteHlsPartialStreamFiles(string outputFilePath) { - var directory = _fileSystem.GetDirectoryName(outputFilePath); + var directory = Path.GetDirectoryName(outputFilePath); var name = Path.GetFileNameWithoutExtension(outputFilePath); var filesToDelete = _fileSystem.GetFilePaths(directory) diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index 0fc20749f1..366e9308eb 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -303,7 +303,7 @@ namespace MediaBrowser.Api public object Get(GetParentPath request) { - var parent = _fileSystem.GetDirectoryName(request.Path); + var parent = Path.GetDirectoryName(request.Path); if (string.IsNullOrEmpty(parent)) { diff --git a/MediaBrowser.Api/Images/ImageByNameService.cs b/MediaBrowser.Api/Images/ImageByNameService.cs index 61efae46d4..3ac576b0f2 100644 --- a/MediaBrowser.Api/Images/ImageByNameService.cs +++ b/MediaBrowser.Api/Images/ImageByNameService.cs @@ -158,7 +158,7 @@ namespace MediaBrowser.Api.Images private string GetThemeName(string path, string rootImagePath) { - var parentName = _fileSystem.GetDirectoryName(path); + var parentName = Path.GetDirectoryName(path); if (string.Equals(parentName, rootImagePath, StringComparison.OrdinalIgnoreCase)) { diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 24c8ed8353..cd4d21bac2 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -264,7 +264,7 @@ namespace MediaBrowser.Api.Images var fullCachePath = GetFullCachePath(urlHash + "." + ext); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath)); using (var stream = result.Content) { using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) @@ -273,7 +273,7 @@ namespace MediaBrowser.Api.Images } } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); _fileSystem.WriteAllText(pointerCachePath, fullCachePath); } } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 10d882e08d..05dd93cf78 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -305,7 +305,7 @@ namespace MediaBrowser.Api var fullCachePath = GetFullCachePath(urlHash + "." + ext); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath)); using (var stream = result.Content) { using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) @@ -314,7 +314,7 @@ namespace MediaBrowser.Api } } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); _fileSystem.WriteAllText(pointerCachePath, fullCachePath); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index bb525adc73..f03e934a54 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -192,7 +192,7 @@ namespace MediaBrowser.Api.Playback CancellationTokenSource cancellationTokenSource, string workingDirectory = null) { - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false); @@ -258,7 +258,7 @@ namespace MediaBrowser.Api.Playback } var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt"); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(logFilePath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. state.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 1e90d03b0a..3c41226d0c 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -264,7 +264,7 @@ namespace MediaBrowser.Api.Playback.Hls var useGenericSegmenter = true; if (useGenericSegmenter) { - var outputTsArg = Path.Combine(FileSystem.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request); + var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request); var timeDeltaParam = string.Empty; diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index b3099e17e6..c30ad67ecd 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -381,7 +381,7 @@ namespace MediaBrowser.Api.Playback.Hls private static FileSystemMetadata GetLastTranscodingFile(string playlist, string segmentExtension, IFileSystem fileSystem) { - var folder = fileSystem.GetDirectoryName(playlist); + var folder = Path.GetDirectoryName(playlist); var filePrefix = Path.GetFileNameWithoutExtension(playlist) ?? string.Empty; @@ -418,7 +418,7 @@ namespace MediaBrowser.Api.Playback.Hls private string GetSegmentPath(StreamState state, string playlist, int index) { - var folder = FileSystem.GetDirectoryName(playlist); + var folder = Path.GetDirectoryName(playlist); var filename = Path.GetFileNameWithoutExtension(playlist); @@ -932,7 +932,7 @@ namespace MediaBrowser.Api.Playback.Hls var mapArgs = state.IsOutputVideo ? EncodingHelper.GetMapArgs(state) : string.Empty; - var outputTsArg = Path.Combine(FileSystem.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request); + var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request); var timeDeltaParam = string.Empty; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 846fd9eec4..096cc7016e 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -228,7 +228,7 @@ namespace MediaBrowser.Controller.Entities return Path; } - return FileSystem.GetDirectoryName(Path); + return System.IO.Path.GetDirectoryName(Path); } } @@ -2208,7 +2208,7 @@ namespace MediaBrowser.Controller.Entities { var allFiles = ImageInfos .Where(i => i.IsLocalFile) - .Select(i => FileSystem.GetDirectoryName(i.Path)) + .Select(i => System.IO.Path.GetDirectoryName(i.Path)) .Distinct(StringComparer.OrdinalIgnoreCase) .SelectMany(i => directoryService.GetFilePaths(i)) .ToList(); @@ -2396,7 +2396,7 @@ namespace MediaBrowser.Controller.Entities var extensions = new List { ".nfo", ".xml", ".srt", ".vtt", ".sub", ".idx", ".txt", ".edl", ".bif", ".smi", ".ttml" }; extensions.AddRange(SupportedImageExtensions); - return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(), false, false) + return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false) .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase)) .ToList(); } diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index 82a4531ff0..eea1bf43df 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -87,7 +87,7 @@ namespace MediaBrowser.Controller.Entities return new[] { new FileSystemMetadata { - FullName = FileSystem.GetDirectoryName(Path), + FullName = System.IO.Path.GetDirectoryName(Path), IsDirectory = true } }; diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index b40009e0c7..5d7c260d15 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -97,7 +97,7 @@ namespace MediaBrowser.Controller.Entities.TV return series.Path; } - return FileSystem.GetDirectoryName(Path); + return System.IO.Path.GetDirectoryName(Path); } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index dd4440c3b6..33a9677585 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -345,7 +345,7 @@ namespace MediaBrowser.Controller.Entities { if (IsStacked) { - return FileSystem.GetDirectoryName(Path); + return System.IO.Path.GetDirectoryName(Path); } if (!IsPlaceHolder) diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 7bb8325f8c..0222b926e9 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -85,7 +85,7 @@ namespace MediaBrowser.Controller.Library return false; } - var parentDir = BaseItem.FileSystem.GetDirectoryName(Path) ?? string.Empty; + var parentDir = System.IO.Path.GetDirectoryName(Path) ?? string.Empty; return parentDir.Length > _appPaths.RootFolderPath.Length && parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase); diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 9696436608..e832607251 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Playlists if (IsPlaylistFile(path)) { - return FileSystem.GetDirectoryName(path); + return System.IO.Path.GetDirectoryName(path); } return path; diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 894f461296..16f280982d 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; @@ -29,7 +30,7 @@ namespace MediaBrowser.LocalMetadata.Images public List GetImages(BaseItem item, IDirectoryService directoryService) { - var parentPath = _fileSystem.GetDirectoryName(item.Path); + var parentPath = Path.GetDirectoryName(item.Path); var parentPathFiles = directoryService.GetFiles(parentPath); diff --git a/MediaBrowser.LocalMetadata/Providers/GameXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/GameXmlProvider.cs index 537bd073c5..acdbb0a29b 100644 --- a/MediaBrowser.LocalMetadata/Providers/GameXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/Providers/GameXmlProvider.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.LocalMetadata.Providers var specificFile = Path.ChangeExtension(info.Path, ".xml"); var file = FileSystem.GetFileInfo(specificFile); - return info.IsInMixedFolder || file.Exists ? file : FileSystem.GetFileInfo(Path.Combine(FileSystem.GetDirectoryName(info.Path), "game.xml")); + return info.IsInMixedFolder || file.Exists ? file : FileSystem.GetFileInfo(Path.Combine(Path.GetDirectoryName(info.Path), "game.xml")); } } } diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index 2eac35f282..2a9740806e 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -94,7 +94,7 @@ namespace MediaBrowser.LocalMetadata.Savers private void SaveToFile(Stream stream, string path) { - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path)); + FileSystem.CreateDirectory(Path.GetDirectoryName(path)); // On Windows, savint the file will fail if the file is hidden or readonly FileSystem.SetAttributes(path, false, false); diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index ed4c445cd1..efc4c30974 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.MediaEncoding.Encoder .CreateJob(options, EncodingHelper, IsVideoEncoder, progress, cancellationToken).ConfigureAwait(false); encodingJob.OutputFilePath = GetOutputFilePath(encodingJob); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(encodingJob.OutputFilePath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(encodingJob.OutputFilePath)); encodingJob.ReadInputAtNativeFramerate = options.ReadInputAtNativeFramerate; @@ -105,7 +105,7 @@ namespace MediaBrowser.MediaEncoding.Encoder Logger.LogInformation(commandLineLogMessage); var logFilePath = Path.Combine(ConfigurationManager.CommonApplicationPaths.LogDirectoryPath, "transcode-" + Guid.NewGuid() + ".txt"); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(logFilePath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. encodingJob.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index d9c1784318..56842f7141 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -353,7 +353,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private string GetProbePathFromEncoderPath(string appPath) { - return FileSystem.GetFilePaths(FileSystem.GetDirectoryName(appPath)) + return FileSystem.GetFilePaths(Path.GetDirectoryName(appPath)) .FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase)); } @@ -608,7 +608,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } var tempExtractPath = Path.Combine(ConfigurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".jpg"); - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(tempExtractPath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(tempExtractPath)); // apply some filters to thumbnail extracted below (below) crop any black lines that we made and get the correct ar then scale to width 600. // This filter chain may have adverse effects on recorded tv thumbnails if ar changes during presentation ex. commercials @ diff ar diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 2f9eb98eae..9690f16f69 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -422,7 +422,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles throw new ArgumentNullException(nameof(outputPath)); } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); var encodingParam = await GetSubtitleFileCharacterSet(inputPath, language, inputProtocol, cancellationToken).ConfigureAwait(false); @@ -565,7 +565,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles throw new ArgumentNullException(nameof(outputPath)); } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s {2} \"{3}\"", inputPath, subtitleStreamIndex, outputCodec, outputPath); diff --git a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs b/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs index e06d93520a..447eefcc8a 100644 --- a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs +++ b/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs @@ -156,7 +156,7 @@ namespace MediaBrowser.Providers.BoxSets var dataFilePath = GetDataFilePath(_config.ApplicationPaths, tmdbId, preferredMetadataLanguage); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _json.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index d0d00ef127..f37532aebe 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -233,14 +233,14 @@ namespace MediaBrowser.Providers.Manager { _logger.LogDebug("Saving image to {0}", path); - var parentFolder = _fileSystem.GetDirectoryName(path); + var parentFolder = Path.GetDirectoryName(path); try { _libraryMonitor.ReportFileSystemChangeBeginning(path); _libraryMonitor.ReportFileSystemChangeBeginning(parentFolder); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); _fileSystem.SetAttributes(path, false, false); @@ -437,7 +437,7 @@ namespace MediaBrowser.Providers.Manager { if (type == ImageType.Primary && item is Episode) { - path = Path.Combine(_fileSystem.GetDirectoryName(item.Path), "metadata", filename + extension); + path = Path.Combine(Path.GetDirectoryName(item.Path), "metadata", filename + extension); } else if (item.IsInMixedFolder) @@ -569,7 +569,7 @@ namespace MediaBrowser.Providers.Manager if (item is Episode) { - var seasonFolder = _fileSystem.GetDirectoryName(item.Path); + var seasonFolder = Path.GetDirectoryName(item.Path); var imageFilename = _fileSystem.GetFileNameWithoutExtension(item.Path) + "-thumb" + extension; @@ -617,7 +617,7 @@ namespace MediaBrowser.Providers.Manager { imageFilename = "poster"; } - var folder = _fileSystem.GetDirectoryName(item.Path); + var folder = Path.GetDirectoryName(item.Path); return Path.Combine(folder, _fileSystem.GetFileNameWithoutExtension(item.Path) + "-" + imageFilename + extension); } diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index 0b902ccecb..47251afc53 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.Providers.MediaInfo if (!_fileSystem.FileExists(path)) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ?? imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ?? diff --git a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs index 63d99db9b6..aa6752d8f9 100644 --- a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs +++ b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs @@ -254,7 +254,7 @@ namespace MediaBrowser.Providers.Movies var path = GetFanartJsonPath(id); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); try { diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index 10d3e5e9d1..4846e22813 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; using System.Net; using System.Threading; @@ -91,7 +92,7 @@ namespace MediaBrowser.Providers.Movies tmdbId = movieInfo.id.ToString(_usCulture); dataFilePath = MovieDbProvider.Current.GetDataFilePath(tmdbId, language); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(movieInfo, dataFilePath); } } diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index f03a8c2c28..8b185c6683 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.Movies var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs b/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs index 3c4855806c..6b3f32befa 100644 --- a/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs @@ -153,7 +153,7 @@ namespace MediaBrowser.Providers.Music var path = GetAlbumInfoPath(_config.ApplicationPaths, musicBrainzReleaseGroupId); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); using (var httpResponse = await _httpClient.SendAsync(new HttpRequestOptions { diff --git a/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs b/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs index 03eefc2eb3..769a0a3258 100644 --- a/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs +++ b/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Providers.Music { using (var response = httpResponse.Content) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); using (var xmlFileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) { diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index a7456bdc0e..48db5576e7 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -233,7 +233,7 @@ namespace MediaBrowser.Providers.Music var jsonPath = GetArtistJsonPath(_config.ApplicationPaths, musicBrainzId); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(jsonPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(jsonPath)); try { diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index c529077457..d37105c0c4 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -294,7 +294,7 @@ namespace MediaBrowser.Providers.Omdb using (var stream = response.Content) { var rootObject = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(rootObject, path); } } @@ -331,7 +331,7 @@ namespace MediaBrowser.Providers.Omdb using (var stream = response.Content) { var rootObject = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(rootObject, path); } } diff --git a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs index dc6ce842e5..01d0febbe5 100644 --- a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs +++ b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs @@ -229,7 +229,7 @@ namespace MediaBrowser.Providers.People { using (var json = response.Content) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); using (var fs = _fileSystem.GetFileStream(dataFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) { diff --git a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs index 481f0d01f5..a55a778c26 100644 --- a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs +++ b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Providers.Studios }).ConfigureAwait(false); - fileSystem.CreateDirectory(fileSystem.GetDirectoryName(file)); + fileSystem.CreateDirectory(Path.GetDirectoryName(file)); try { diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 468ba730ab..ac20facd1d 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -217,7 +217,7 @@ namespace MediaBrowser.Providers.Subtitles try { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(savePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(savePath)); using (var fs = _fileSystem.GetFileStream(savePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) { diff --git a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs index 7f3bc323e3..dd14bc5717 100644 --- a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs @@ -298,7 +298,7 @@ namespace MediaBrowser.Providers.TV var path = GetFanartJsonPath(tvdbId); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); try { diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs index 3df3cf8b8f..87e1af08a2 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs @@ -101,7 +101,7 @@ namespace MediaBrowser.Providers.TV var dataFilePath = GetDataFilePath(id, seasonNumber, episodeNumber, preferredMetadataLanguage); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs index 8d13cc726c..e00851962e 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs @@ -188,7 +188,7 @@ namespace MediaBrowser.Providers.TV var dataFilePath = GetDataFilePath(id, seasonNumber, preferredMetadataLanguage); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs index c20cbc4193..5f1127b133 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs @@ -187,7 +187,7 @@ namespace MediaBrowser.Providers.TV tmdbId = seriesInfo.id.ToString(_usCulture); string dataFilePath = GetDataFilePath(tmdbId, language); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(seriesInfo, dataFilePath); await EnsureSeriesInfo(tmdbId, language, cancellationToken).ConfigureAwait(false); @@ -351,7 +351,7 @@ namespace MediaBrowser.Providers.TV var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index c4edb43ffe..7e2d54b903 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -197,7 +197,7 @@ namespace MediaBrowser.Providers.TV if (searchInfo.IndexNumber.HasValue) { - var files = GetEpisodeXmlFiles(searchInfo.SeriesDisplayOrder, searchInfo.ParentIndexNumber, searchInfo.IndexNumber, searchInfo.IndexNumberEnd, _fileSystem.GetDirectoryName(xmlFile)); + var files = GetEpisodeXmlFiles(searchInfo.SeriesDisplayOrder, searchInfo.ParentIndexNumber, searchInfo.IndexNumber, searchInfo.IndexNumberEnd, Path.GetDirectoryName(xmlFile)); list = files.Select(GetXmlReader).ToList(); } diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 1efffff3dc..5322457f02 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -193,7 +193,7 @@ namespace MediaBrowser.XbmcMetadata.Savers private void SaveToFile(Stream stream, string path) { - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path)); + FileSystem.CreateDirectory(Path.GetDirectoryName(path)); // On Windows, savint the file will fail if the file is hidden or readonly FileSystem.SetAttributes(path, false, false); From d7c6d1625043fb69a90e7ccb24fc31a912c8a2d3 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 22:08:04 +0100 Subject: [PATCH 15/27] Unwrapped CreateDirectory and DeleteDirectory --- Emby.Dlna/DlnaManager.cs | 4 +-- Emby.Drawing/ImageProcessor.cs | 2 +- .../IsoMounter/LinuxIsoManager.cs | 6 ++--- .../AppBase/BaseConfigurationManager.cs | 4 +-- .../AppBase/ConfigurationHelper.cs | 2 +- .../Channels/ChannelManager.cs | 4 +-- .../Collections/CollectionManager.cs | 4 +-- .../Devices/DeviceId.cs | 2 +- .../Devices/DeviceManager.cs | 8 +++--- .../FFMpeg/FFMpegLoader.cs | 2 +- .../HttpClientManager/HttpClientManager.cs | 4 +-- .../Images/BaseDynamicImageProvider.cs | 4 +-- .../Library/LibraryManager.cs | 26 +++++++++---------- .../Library/MediaSourceManager.cs | 2 +- .../Library/UserManager.cs | 4 +-- .../LiveTv/EmbyTV/DirectRecorder.cs | 4 +-- .../LiveTv/EmbyTV/EncodedRecorder.cs | 4 +-- .../LiveTv/EmbyTV/ItemDataProvider.cs | 2 +- .../LiveTv/Listings/XmlTvListingsProvider.cs | 6 ++--- .../LiveTv/TunerHosts/BaseTunerHost.cs | 2 +- .../HdHomerun/HdHomerunUdpStream.cs | 2 +- .../LiveTv/TunerHosts/SharedHttpStream.cs | 2 +- .../Localization/LocalizationManager.cs | 2 +- .../MediaEncoder/EncodingManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 2 +- .../ScheduledTasks/ChapterImagesTask.cs | 2 +- .../ScheduledTasks/ScheduledTaskWorker.cs | 4 +-- .../Tasks/DeleteCacheFileTask.cs | 2 +- .../Updates/InstallationManager.cs | 2 +- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 6 ++--- MediaBrowser.Api/Images/RemoteImageService.cs | 4 +-- MediaBrowser.Api/ItemLookupService.cs | 4 +-- .../Playback/BaseStreamingService.cs | 4 +-- MediaBrowser.Controller/Entities/User.cs | 5 ++-- .../Savers/BaseXmlSaver.cs | 2 +- .../Encoder/BaseEncoder.cs | 4 +-- .../Encoder/MediaEncoder.cs | 4 +-- .../Subtitles/SubtitleEncoder.cs | 4 +-- .../BoxSets/MovieDbBoxSetProvider.cs | 2 +- MediaBrowser.Providers/Manager/ImageSaver.cs | 2 +- .../MediaInfo/AudioImageProvider.cs | 2 +- .../Movies/FanartMovieImageProvider.cs | 2 +- .../Movies/GenericMovieDbInfo.cs | 2 +- .../Movies/MovieDbProvider.cs | 2 +- .../Music/AudioDbAlbumProvider.cs | 2 +- .../Music/AudioDbArtistProvider.cs | 2 +- .../Music/FanArtArtistProvider.cs | 2 +- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 4 +-- .../People/MovieDbPersonProvider.cs | 2 +- .../Studios/StudiosImageProvider.cs | 2 +- .../Subtitles/SubtitleManager.cs | 2 +- .../TV/FanArt/FanartSeriesProvider.cs | 2 +- .../TV/TheMovieDb/MovieDbProviderBase.cs | 2 +- .../TV/TheMovieDb/MovieDbSeasonProvider.cs | 2 +- .../TV/TheMovieDb/MovieDbSeriesProvider.cs | 4 +-- .../TV/TheTVDB/TvdbPrescanTask.cs | 4 +-- .../Api/DashboardService.cs | 6 ++--- .../Savers/BaseNfoSaver.cs | 2 +- 58 files changed, 102 insertions(+), 101 deletions(-) diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index f795b58cbb..fd7b408fd7 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -379,7 +379,7 @@ namespace Emby.Dlna if (!fileInfo.Exists || fileInfo.Length != stream.Length) { - _fileSystem.CreateDirectory(systemProfilesPath); + Directory.CreateDirectory(systemProfilesPath); using (var fileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { @@ -390,7 +390,7 @@ namespace Emby.Dlna } // Not necessary, but just to make it easy to find - _fileSystem.CreateDirectory(UserProfilesPath); + Directory.CreateDirectory(UserProfilesPath); } public void DeleteProfile(string id) diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index ec50798aa9..c873802185 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -631,7 +631,7 @@ namespace Emby.Drawing return (enhancedImagePath, treatmentRequiresTransparency); } - _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); + Directory.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, enhancedImagePath, item, imageType, imageIndex).ConfigureAwait(false); diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index 611e4263ca..a3ba6f7df8 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs @@ -327,7 +327,7 @@ namespace IsoMounter try { - FileSystem.CreateDirectory(mountPoint); + Directory.CreateDirectory(mountPoint); } catch (UnauthorizedAccessException) { @@ -377,7 +377,7 @@ namespace IsoMounter try { - FileSystem.DeleteDirectory(mountPoint, false); + Directory.Delete(mountPoint, false); } catch (Exception ex) { @@ -455,7 +455,7 @@ namespace IsoMounter try { - FileSystem.DeleteDirectory(mount.MountedPath, false); + Directory.Delete(mount.MountedPath, false); } catch (Exception ex) { diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 312ef14c48..b9f0701a67 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.AppBase Logger.LogInformation("Saving system configuration"); var path = CommonApplicationPaths.SystemConfigurationFilePath; - FileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_configurationSyncLock) { @@ -294,7 +294,7 @@ namespace Emby.Server.Implementations.AppBase _configurations.AddOrUpdate(key, configuration, (k, v) => configuration); var path = GetConfigurationFile(key); - FileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_configurationSyncLock) { diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index 5c386d3efb..b9af663a95 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.AppBase // If the file didn't exist before, or if something has changed, re-save if (buffer == null || !buffer.SequenceEqual(newBytes)) { - fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); // Save it after load in case we got new items fileSystem.WriteAllBytes(path, newBytes); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 3878928011..949b892265 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -355,7 +355,7 @@ namespace Emby.Server.Implementations.Channels return; } - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(mediaSources, path); } @@ -834,7 +834,7 @@ namespace Emby.Server.Implementations.Channels { try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(result, path); } diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 0166bbc5ab..1bed658167 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Collections return null; } - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); var libraryOptions = new LibraryOptions { @@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.Collections try { - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); var collection = new BoxSet { diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 6092428c8b..9640e7abb1 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Devices { var path = CachePath; - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_syncLock) { diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index b8521f9b2a..1958ae83b7 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Devices public void SaveCapabilities(string deviceId, ClientCapabilities capabilities) { var path = Path.Combine(GetDevicePath(deviceId), "capabilities.json"); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_capabilitiesSyncLock) { @@ -239,7 +239,7 @@ namespace Emby.Server.Implementations.Devices path = Path.Combine(path, file.Name); path = Path.ChangeExtension(path, MimeTypes.ToExtension(file.MimeType) ?? "jpg"); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); await EnsureLibraryFolder(uploadPathInfo.Item2, uploadPathInfo.Item3).ConfigureAwait(false); @@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Devices private void AddCameraUpload(string deviceId, LocalFileInfo file) { var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json"); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_cameraUploadSyncLock) { @@ -317,7 +317,7 @@ namespace Emby.Server.Implementations.Devices return Task.CompletedTask; } - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); var libraryOptions = new LibraryOptions { diff --git a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs index 63d1215d82..cf12a8294e 100644 --- a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs +++ b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs @@ -75,7 +75,7 @@ namespace Emby.Server.Implementations.FFMpeg Version = version }; - _fileSystem.CreateDirectory(versionedDirectoryPath); + Directory.CreateDirectory(versionedDirectoryPath); var excludeFromDeletions = new List { versionedDirectoryPath }; diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index a4902fc786..a61247fd1d 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -305,7 +305,7 @@ namespace Emby.Server.Implementations.HttpClientManager private async Task CacheResponse(HttpResponseInfo response, string responseCachePath) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath)); + Directory.CreateDirectory(Path.GetDirectoryName(responseCachePath)); using (var fileStream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true)) { @@ -513,7 +513,7 @@ namespace Emby.Server.Implementations.HttpClientManager { ValidateParams(options); - _fileSystem.CreateDirectory(_appPaths.TempDirectory); + Directory.CreateDirectory(_appPaths.TempDirectory); var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp"); diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index 24152d3de7..1602b9f9d9 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Images CancellationToken cancellationToken) { var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N")); - FileSystem.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension)); string outputPath = CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0); if (string.IsNullOrEmpty(outputPath)) @@ -165,7 +165,7 @@ namespace Emby.Server.Implementations.Images private string CreateCollage(BaseItem primaryItem, List items, string outputPath, int width, int height) { - FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); var options = new ImageCollageOptions { diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 89881d730c..7b6372fe80 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -375,7 +375,7 @@ namespace Emby.Server.Implementations.Library try { - _fileSystem.DeleteDirectory(metadataPath, true); + Directory.Delete(metadataPath, true); } catch (IOException) { @@ -402,11 +402,11 @@ namespace Emby.Server.Implementations.Library _logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName); if (fileSystemInfo.IsDirectory) { - _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true); + Directory.Delete(fileSystemInfo.FullName, true); } else { - _fileSystem.DeleteFile(fileSystemInfo.FullName); + File.Delete(fileSystemInfo.FullName); } } catch (IOException) @@ -720,7 +720,7 @@ namespace Emby.Server.Implementations.Library { var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath; - _fileSystem.CreateDirectory(rootFolderPath); + Directory.CreateDirectory(rootFolderPath); var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ?? ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(rootFolderPath))).DeepCopy(); @@ -734,7 +734,7 @@ namespace Emby.Server.Implementations.Library // Add in the plug-in folders var path = Path.Combine(ConfigurationManager.ApplicationPaths.DataPath, "playlists"); - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); Folder folder = new PlaylistsFolder { @@ -785,7 +785,7 @@ namespace Emby.Server.Implementations.Library { var userRootPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; - _fileSystem.CreateDirectory(userRootPath); + Directory.CreateDirectory(userRootPath); var tmpItem = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder; @@ -999,7 +999,7 @@ namespace Emby.Server.Implementations.Library public Task ValidatePeople(CancellationToken cancellationToken, IProgress progress) { // Ensure the location is available. - _fileSystem.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath); + Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath); return new PeopleValidator(this, _logger, ConfigurationManager, _fileSystem).ValidatePeople(cancellationToken, progress); } @@ -2146,7 +2146,7 @@ namespace Emby.Server.Implementations.Library if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase)) { - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); item = new UserView { @@ -2191,7 +2191,7 @@ namespace Emby.Server.Implementations.Library if (item == null) { - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); item = new UserView { @@ -2256,7 +2256,7 @@ namespace Emby.Server.Implementations.Library if (item == null) { - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); item = new UserView { @@ -2324,7 +2324,7 @@ namespace Emby.Server.Implementations.Library if (item == null) { - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); item = new UserView { @@ -2883,7 +2883,7 @@ namespace Emby.Server.Implementations.Library try { - _fileSystem.CreateDirectory(virtualFolderPath); + Directory.CreateDirectory(virtualFolderPath); if (!string.IsNullOrEmpty(collectionType)) { @@ -3082,7 +3082,7 @@ namespace Emby.Server.Implementations.Library try { - _fileSystem.DeleteDirectory(path, true); + Directory.Delete(path, true); } finally { diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index 17f69909f3..b83fb9b397 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -670,7 +670,7 @@ namespace Emby.Server.Implementations.Library if (cacheFilePath != null) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); _jsonSerializer.SerializeToFile(mediaInfo, cacheFilePath); //_logger.LogDebug("Saved media info to {0}", cacheFilePath); diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 04787add94..0b87455a43 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -1080,7 +1080,7 @@ namespace Emby.Server.Implementations.Library var path = GetPolicyFilePath(user); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_policySyncLock) { @@ -1176,7 +1176,7 @@ namespace Emby.Server.Implementations.Library config = _jsonSerializer.DeserializeFromString(json); } - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_configSyncLock) { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs index 950b0b3606..dd636e6cdf 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs @@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private async Task RecordFromDirectStreamProvider(IDirectStreamProvider directStreamProvider, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile)); + Directory.CreateDirectory(Path.GetDirectoryName(targetFile)); using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { @@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { _logger.LogInformation("Opened recording stream from tuner provider"); - _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile)); + Directory.CreateDirectory(Path.GetDirectoryName(targetFile)); using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) { diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index ec65f90b91..eed2395141 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken) { _targetPath = targetFile; - _fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile)); + Directory.CreateDirectory(Path.GetDirectoryName(targetFile)); var process = _processFactory.Create(new ProcessOptions { @@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _logger.LogInformation(commandLineLogMessage); var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "record-transcode-" + Guid.NewGuid() + ".txt"); - _fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. _logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index d3972d9e0b..6b02eaea82 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } var file = _dataPath + ".json"; - _fileSystem.CreateDirectory(Path.GetDirectoryName(file)); + Directory.CreateDirectory(Path.GetDirectoryName(file)); lock (_fileDataLock) { diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 6e5d037f76..268510e0b7 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -83,7 +83,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings }).ConfigureAwait(false); - _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFile)); + Directory.CreateDirectory(Path.GetDirectoryName(cacheFile)); _fileSystem.CopyFile(tempFile, cacheFile, true); @@ -125,7 +125,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings using (var stream = _fileSystem.OpenRead(file)) { string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString()); - _fileSystem.CreateDirectory(tempFolder); + Directory.CreateDirectory(tempFolder); _zipClient.ExtractFirstFileFromGz(stream, tempFolder, "data.xml"); @@ -138,7 +138,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings using (var stream = _fileSystem.OpenRead(file)) { string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString()); - _fileSystem.CreateDirectory(tempFolder); + Directory.CreateDirectory(tempFolder); _zipClient.ExtractAllFromGz(stream, tempFolder, true); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs index 6a51cd98c9..6d1eff187c 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { try { - FileSystem.CreateDirectory(Path.GetDirectoryName(channelCacheFile)); + Directory.CreateDirectory(Path.GetDirectoryName(channelCacheFile)); JsonSerializer.SerializeToFile(channels, channelCacheFile); } catch (IOException) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs index 045d8bb205..8774371d52 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var uri = new Uri(mediaSource.Path); var localPort = _networkManager.GetRandomUnusedUdpPort(); - FileSystem.CreateDirectory(Path.GetDirectoryName(TempFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(TempFilePath)); Logger.LogInformation("Opening HDHR UDP Live stream from {host}", uri.Host); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs index 3c1cd9e7c2..716417ccbc 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs @@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts var url = mediaSource.Path; - FileSystem.CreateDirectory(Path.GetDirectoryName(TempFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(TempFilePath)); var typeName = GetType().Name; Logger.LogInformation("Opening " + typeName + " Live stream from {0}", url); diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index ce3d00f156..140ee5f9af 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Localization var localizationPath = LocalizationPath; - _fileSystem.CreateDirectory(localizationPath); + Directory.CreateDirectory(localizationPath); var existingFiles = GetRatingsFiles(localizationPath) .Select(Path.GetFileName) diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 09141567ee..93bc0c3b2c 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -141,7 +141,7 @@ namespace Emby.Server.Implementations.MediaEncoder var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, Array.Empty()); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); var container = video.Container; diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index d428a32223..32be5648d5 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.Playlists try { - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); var playlist = new Playlist { diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index 93926da3e2..4124063f07 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -141,7 +141,7 @@ namespace Emby.Server.Implementations.ScheduledTasks var parentPath = Path.GetDirectoryName(failHistoryPath); - _fileSystem.CreateDirectory(parentPath); + Directory.CreateDirectory(parentPath); _fileSystem.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray())); } diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 3c53b84abe..2b648b04b6 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.ScheduledTasks _lastExecutionResult = value; var path = GetHistoryFilePath(); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); lock (_lastExecutionResultSyncLock) { @@ -565,7 +565,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { var path = GetConfigurationFilePath(); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); JsonSerializer.SerializeToFile(triggers, path); } diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index 2590f455c6..52077b242e 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks { try { - _fileSystem.DeleteDirectory(directory, false); + Directory.Delete(directory, false); } catch (UnauthorizedAccessException ex) { diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index b9fd404af7..93c8a3361e 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -570,7 +570,7 @@ namespace Emby.Server.Implementations.Updates // Success - move it to the real target try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(target)); + Directory.CreateDirectory(Path.GetDirectoryName(target)); _fileSystem.CopyFile(tempFile, target, true); //If it is an archive - write out a version file so we know what it is if (isArchive) diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 3261c970dd..552eda7201 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -219,7 +219,7 @@ namespace Jellyfin.Drawing.Skia var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + Path.GetExtension(path) ?? string.Empty); - fileSystem.CreateDirectory(Path.GetDirectoryName(tempPath)); + Directory.CreateDirectory(Path.GetDirectoryName(tempPath)); fileSystem.CopyFile(path, tempPath, true); return tempPath; @@ -532,7 +532,7 @@ namespace Jellyfin.Drawing.Skia // If all we're doing is resizing then we can stop now if (!hasBackgroundColor && !hasForegroundColor && blur == 0 && !hasIndicator) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); using (var outputStream = new SKFileWStream(outputPath)) using (var pixmap = new SKPixmap(new SKImageInfo(width, height), resizedBitmap.GetPixels())) { @@ -584,7 +584,7 @@ namespace Jellyfin.Drawing.Skia DrawIndicator(canvas, width, height, options); } - _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); using (var outputStream = new SKFileWStream(outputPath)) { using (var pixmap = new SKPixmap(new SKImageInfo(width, height), saveBitmap.GetPixels())) diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index cd4d21bac2..3a1ebced52 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -264,7 +264,7 @@ namespace MediaBrowser.Api.Images var fullCachePath = GetFullCachePath(urlHash + "." + ext); - _fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath)); + Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath)); using (var stream = result.Content) { using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) @@ -273,7 +273,7 @@ namespace MediaBrowser.Api.Images } } - _fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); + Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); _fileSystem.WriteAllText(pointerCachePath, fullCachePath); } } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 05dd93cf78..eaf2d1e1b0 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -305,7 +305,7 @@ namespace MediaBrowser.Api var fullCachePath = GetFullCachePath(urlHash + "." + ext); - _fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath)); + Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath)); using (var stream = result.Content) { using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) @@ -314,7 +314,7 @@ namespace MediaBrowser.Api } } - _fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); + Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); _fileSystem.WriteAllText(pointerCachePath, fullCachePath); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index f03e934a54..07e84536fc 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -192,7 +192,7 @@ namespace MediaBrowser.Api.Playback CancellationTokenSource cancellationTokenSource, string workingDirectory = null) { - FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false); @@ -258,7 +258,7 @@ namespace MediaBrowser.Api.Playback } var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt"); - FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. state.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 10fe096a46..ea2ea9a506 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; @@ -169,7 +170,7 @@ namespace MediaBrowser.Controller.Entities // Exceptions will be thrown if these paths already exist if (FileSystem.DirectoryExists(newConfigDirectory)) { - FileSystem.DeleteDirectory(newConfigDirectory, true); + Directory.Delete(newConfigDirectory, true); } if (FileSystem.DirectoryExists(oldConfigurationDirectory)) @@ -178,7 +179,7 @@ namespace MediaBrowser.Controller.Entities } else { - FileSystem.CreateDirectory(newConfigDirectory); + Directory.CreateDirectory(newConfigDirectory); } } diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index 2a9740806e..8a291e6a83 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -94,7 +94,7 @@ namespace MediaBrowser.LocalMetadata.Savers private void SaveToFile(Stream stream, string path) { - FileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); // On Windows, savint the file will fail if the file is hidden or readonly FileSystem.SetAttributes(path, false, false); diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index efc4c30974..2d43b82562 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.MediaEncoding.Encoder .CreateJob(options, EncodingHelper, IsVideoEncoder, progress, cancellationToken).ConfigureAwait(false); encodingJob.OutputFilePath = GetOutputFilePath(encodingJob); - FileSystem.CreateDirectory(Path.GetDirectoryName(encodingJob.OutputFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(encodingJob.OutputFilePath)); encodingJob.ReadInputAtNativeFramerate = options.ReadInputAtNativeFramerate; @@ -105,7 +105,7 @@ namespace MediaBrowser.MediaEncoding.Encoder Logger.LogInformation(commandLineLogMessage); var logFilePath = Path.Combine(ConfigurationManager.CommonApplicationPaths.LogDirectoryPath, "transcode-" + Guid.NewGuid() + ".txt"); - FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. encodingJob.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 56842f7141..92e091dc0a 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -608,7 +608,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } var tempExtractPath = Path.Combine(ConfigurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".jpg"); - FileSystem.CreateDirectory(Path.GetDirectoryName(tempExtractPath)); + Directory.CreateDirectory(Path.GetDirectoryName(tempExtractPath)); // apply some filters to thumbnail extracted below (below) crop any black lines that we made and get the correct ar then scale to width 600. // This filter chain may have adverse effects on recorded tv thumbnails if ar changes during presentation ex. commercials @ diff ar @@ -770,7 +770,7 @@ namespace MediaBrowser.MediaEncoding.Encoder vf += string.Format(",scale=min(iw\\,{0}):trunc(ow/dar/2)*2", maxWidthParam); } - FileSystem.CreateDirectory(targetDirectory); + Directory.CreateDirectory(targetDirectory); var outputPath = Path.Combine(targetDirectory, filenamePrefix + "%05d.jpg"); var args = string.Format("-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf); diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 9690f16f69..ab92555e10 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -422,7 +422,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles throw new ArgumentNullException(nameof(outputPath)); } - _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); var encodingParam = await GetSubtitleFileCharacterSet(inputPath, language, inputProtocol, cancellationToken).ConfigureAwait(false); @@ -565,7 +565,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles throw new ArgumentNullException(nameof(outputPath)); } - _fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s {2} \"{3}\"", inputPath, subtitleStreamIndex, outputCodec, outputPath); diff --git a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs b/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs index 447eefcc8a..4e41694c4d 100644 --- a/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs +++ b/MediaBrowser.Providers/BoxSets/MovieDbBoxSetProvider.cs @@ -156,7 +156,7 @@ namespace MediaBrowser.Providers.BoxSets var dataFilePath = GetDataFilePath(_config.ApplicationPaths, tmdbId, preferredMetadataLanguage); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _json.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index f37532aebe..802e02f78a 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -240,7 +240,7 @@ namespace MediaBrowser.Providers.Manager _libraryMonitor.ReportFileSystemChangeBeginning(path); _libraryMonitor.ReportFileSystemChangeBeginning(parentFolder); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); _fileSystem.SetAttributes(path, false, false); diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index 47251afc53..c2e3dd1a17 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.Providers.MediaInfo if (!_fileSystem.FileExists(path)) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ?? imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ?? diff --git a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs index aa6752d8f9..4a94bcb1a2 100644 --- a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs +++ b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs @@ -254,7 +254,7 @@ namespace MediaBrowser.Providers.Movies var path = GetFanartJsonPath(id); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); try { diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index 4846e22813..4300b84a93 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Providers.Movies tmdbId = movieInfo.id.ToString(_usCulture); dataFilePath = MovieDbProvider.Current.GetDataFilePath(tmdbId, language); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(movieInfo, dataFilePath); } } diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index 8b185c6683..c5af5ef363 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.Movies var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs b/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs index 6b3f32befa..7ccf7cffa9 100644 --- a/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs @@ -153,7 +153,7 @@ namespace MediaBrowser.Providers.Music var path = GetAlbumInfoPath(_config.ApplicationPaths, musicBrainzReleaseGroupId); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); using (var httpResponse = await _httpClient.SendAsync(new HttpRequestOptions { diff --git a/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs b/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs index 769a0a3258..2540a6047e 100644 --- a/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs +++ b/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Providers.Music { using (var response = httpResponse.Content) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); using (var xmlFileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) { diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index 48db5576e7..2efeb69851 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -233,7 +233,7 @@ namespace MediaBrowser.Providers.Music var jsonPath = GetArtistJsonPath(_config.ApplicationPaths, musicBrainzId); - _fileSystem.CreateDirectory(Path.GetDirectoryName(jsonPath)); + Directory.CreateDirectory(Path.GetDirectoryName(jsonPath)); try { diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index d37105c0c4..19dce34d69 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -294,7 +294,7 @@ namespace MediaBrowser.Providers.Omdb using (var stream = response.Content) { var rootObject = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(rootObject, path); } } @@ -331,7 +331,7 @@ namespace MediaBrowser.Providers.Omdb using (var stream = response.Content) { var rootObject = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(rootObject, path); } } diff --git a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs index 01d0febbe5..6d9d66f800 100644 --- a/MediaBrowser.Providers/People/MovieDbPersonProvider.cs +++ b/MediaBrowser.Providers/People/MovieDbPersonProvider.cs @@ -229,7 +229,7 @@ namespace MediaBrowser.Providers.People { using (var json = response.Content) { - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); using (var fs = _fileSystem.GetFileStream(dataFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) { diff --git a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs index a55a778c26..a8235fddce 100644 --- a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs +++ b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Providers.Studios }).ConfigureAwait(false); - fileSystem.CreateDirectory(Path.GetDirectoryName(file)); + Directory.CreateDirectory(Path.GetDirectoryName(file)); try { diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index ac20facd1d..4cec8b4a97 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -217,7 +217,7 @@ namespace MediaBrowser.Providers.Subtitles try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(savePath)); + Directory.CreateDirectory(Path.GetDirectoryName(savePath)); using (var fs = _fileSystem.GetFileStream(savePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) { diff --git a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs index dd14bc5717..172a7d2b87 100644 --- a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs @@ -298,7 +298,7 @@ namespace MediaBrowser.Providers.TV var path = GetFanartJsonPath(tvdbId); - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); try { diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs index 87e1af08a2..9f1102946b 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbProviderBase.cs @@ -101,7 +101,7 @@ namespace MediaBrowser.Providers.TV var dataFilePath = GetDataFilePath(id, seasonNumber, episodeNumber, preferredMetadataLanguage); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs index e00851962e..790b38074f 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs @@ -188,7 +188,7 @@ namespace MediaBrowser.Providers.TV var dataFilePath = GetDataFilePath(id, seasonNumber, preferredMetadataLanguage); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs index 5f1127b133..76031a7cdb 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs @@ -187,7 +187,7 @@ namespace MediaBrowser.Providers.TV tmdbId = seriesInfo.id.ToString(_usCulture); string dataFilePath = GetDataFilePath(tmdbId, language); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(seriesInfo, dataFilePath); await EnsureSeriesInfo(tmdbId, language, cancellationToken).ConfigureAwait(false); @@ -351,7 +351,7 @@ namespace MediaBrowser.Providers.TV var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage); - _fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath)); _jsonSerializer.SerializeToFile(mainResult, dataFilePath); } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs index c4a132d452..fc75e2c0af 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs @@ -82,7 +82,7 @@ namespace MediaBrowser.Providers.TV { var path = TvdbSeriesProvider.GetSeriesDataPath(_config.CommonApplicationPaths); - _fileSystem.CreateDirectory(path); + Directory.CreateDirectory(path); var timestampFile = Path.Combine(path, "time.txt"); @@ -390,7 +390,7 @@ namespace MediaBrowser.Providers.TV seriesDataPath = Path.Combine(seriesDataPath, id); - _fileSystem.CreateDirectory(seriesDataPath); + Directory.CreateDirectory(seriesDataPath); return TvdbSeriesProvider.Current.DownloadSeriesZip(id, MetadataProviders.Tvdb.ToString(), null, null, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, cancellationToken); } diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index db00111143..de759492e6 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -390,7 +390,7 @@ namespace MediaBrowser.WebDashboard.Api { try { - _fileSystem.DeleteDirectory(targetPath, true); + Directory.Delete(targetPath, true); } catch (IOException) { @@ -435,11 +435,11 @@ namespace MediaBrowser.WebDashboard.Api private void CopyDirectory(string source, string destination) { - _fileSystem.CreateDirectory(destination); + Directory.CreateDirectory(destination); //Now Create all of the directories foreach (var dirPath in _fileSystem.GetDirectories(source, true)) - _fileSystem.CreateDirectory(dirPath.FullName.Replace(source, destination)); + Directory.CreateDirectory(dirPath.FullName.Replace(source, destination)); //Copy all the files & Replaces any files with the same name foreach (var newPath in _fileSystem.GetFiles(source, true)) diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 5322457f02..2aacec6f05 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -193,7 +193,7 @@ namespace MediaBrowser.XbmcMetadata.Savers private void SaveToFile(Stream stream, string path) { - FileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); // On Windows, savint the file will fail if the file is hidden or readonly FileSystem.SetAttributes(path, false, false); From a430568082b55f2f989924c59e0729808b39226c Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 22:31:59 +0100 Subject: [PATCH 16/27] Unwrapped `OpenRead` and `CopyFile` --- BDInfo/TSPlaylistFile.cs | 4 ++-- BDInfo/TSStreamClipFile.cs | 4 ++-- Emby.Server.Implementations/Archiving/ZipClient.cs | 6 +++--- .../Images/BaseDynamicImageProvider.cs | 2 +- Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 2 +- .../LiveTv/Listings/XmlTvListingsProvider.cs | 6 +++--- Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs | 2 +- .../Localization/LocalizationManager.cs | 2 +- Emby.Server.Implementations/MediaEncoder/EncodingManager.cs | 2 +- Emby.Server.Implementations/ScheduledTasks/TaskManager.cs | 2 +- Emby.Server.Implementations/Serialization/XmlSerializer.cs | 2 +- Emby.Server.Implementations/Updates/InstallationManager.cs | 4 ++-- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 2 +- MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs | 2 +- .../Subtitles/OpenSubtitleDownloader.cs | 2 +- MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs | 4 ++-- MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs | 2 +- MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs | 3 ++- MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs | 2 +- MediaBrowser.Providers/Studios/StudiosImageProvider.cs | 2 +- MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs | 2 +- MediaBrowser.WebDashboard/Api/DashboardService.cs | 2 +- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 4 ++-- MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs | 2 +- 25 files changed, 35 insertions(+), 34 deletions(-) diff --git a/BDInfo/TSPlaylistFile.cs b/BDInfo/TSPlaylistFile.cs index 8c98d44d7a..6e91f6e408 100644 --- a/BDInfo/TSPlaylistFile.cs +++ b/BDInfo/TSPlaylistFile.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -231,7 +231,7 @@ namespace BDInfo Streams.Clear(); StreamClips.Clear(); - fileStream = _fileSystem.OpenRead(FileInfo.FullName); + fileStream = File.OpenRead(FileInfo.FullName); fileReader = new BinaryReader(fileStream); byte[] data = new byte[fileStream.Length]; diff --git a/BDInfo/TSStreamClipFile.cs b/BDInfo/TSStreamClipFile.cs index 3396f4c719..d840542ba9 100644 --- a/BDInfo/TSStreamClipFile.cs +++ b/BDInfo/TSStreamClipFile.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // BDInfo - Blu-ray Video and Audio Analysis Tool // Copyright © 2010 Cinema Squid // @@ -57,7 +57,7 @@ namespace BDInfo #endif Streams.Clear(); - fileStream = _fileSystem.OpenRead(FileInfo.FullName); + fileStream = File.OpenRead(FileInfo.FullName); fileReader = new BinaryReader(fileStream); byte[] data = new byte[fileStream.Length]; diff --git a/Emby.Server.Implementations/Archiving/ZipClient.cs b/Emby.Server.Implementations/Archiving/ZipClient.cs index 84072cde60..1135cf694d 100644 --- a/Emby.Server.Implementations/Archiving/ZipClient.cs +++ b/Emby.Server.Implementations/Archiving/ZipClient.cs @@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Archiving /// if set to true [overwrite existing files]. public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles) { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) + using (var fileStream = File.OpenRead(sourceFile)) { ExtractAll(fileStream, targetPath, overwriteExistingFiles); } @@ -115,7 +115,7 @@ namespace Emby.Server.Implementations.Archiving /// if set to true [overwrite existing files]. public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles) { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) + using (var fileStream = File.OpenRead(sourceFile)) { ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles); } @@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.Archiving /// if set to true [overwrite existing files]. public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles) { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) + using (var fileStream = File.OpenRead(sourceFile)) { ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles); } diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index 1602b9f9d9..9705d54c9c 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -300,7 +300,7 @@ namespace Emby.Server.Implementations.Images var ext = Path.GetExtension(image); var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext); - FileSystem.CopyFile(image, outputPath, true); + File.Copy(image, outputPath, true); return outputPath; } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index f28f8d7320..762509e749 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1827,7 +1827,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV // preserve original image extension imageSavePath = Path.ChangeExtension(imageSavePath, Path.GetExtension(image.Path)); - _fileSystem.CopyFile(image.Path, imageSavePath, true); + File.Copy(image.Path, imageSavePath, true); } private async Task SaveRecordingImages(string recordingPath, LiveTvProgram program) diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 268510e0b7..dccff65439 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -85,7 +85,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings Directory.CreateDirectory(Path.GetDirectoryName(cacheFile)); - _fileSystem.CopyFile(tempFile, cacheFile, true); + File.Copy(tempFile, cacheFile, true); return UnzipIfNeeded(path, cacheFile); } @@ -122,7 +122,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings private string ExtractFirstFileFromGz(string file) { - using (var stream = _fileSystem.OpenRead(file)) + using (var stream = File.OpenRead(file)) { string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString()); Directory.CreateDirectory(tempFolder); @@ -135,7 +135,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings private string ExtractGz(string file) { - using (var stream = _fileSystem.OpenRead(file)) + using (var stream = File.OpenRead(file)) { string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString()); Directory.CreateDirectory(tempFolder); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index a54a53b254..9a01c42d3b 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts UserAgent = _appHost.ApplicationUserAgent }); } - return Task.FromResult(_fileSystem.OpenRead(url)); + return Task.FromResult((Stream)File.OpenRead(url)); } const string ExtInfPrefix = "#EXTINF:"; diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 140ee5f9af..7af8cf18cc 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -316,7 +316,7 @@ namespace Emby.Server.Implementations.Localization /// Dictionary{System.StringParentalRating}. private void LoadRatings(string file) { - var dict = _fileSystem.ReadAllLines(file).Select(i => + var dict = File.ReadAllLines(file).Select(i => { if (!string.IsNullOrWhiteSpace(i)) { diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 93bc0c3b2c..e68046f6d7 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.MediaEncoder var container = video.Container; var tempFile = await _encoder.ExtractVideoImage(inputPath, container, protocol, video.GetDefaultVideoStream(), video.Video3DFormat, time, cancellationToken).ConfigureAwait(false); - _fileSystem.CopyFile(tempFile, path, true); + File.Copy(tempFile, path, true); try { diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index d74c8fe8c9..b8479fd26a 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.ScheduledTasks try { - lines = _fileSystem.ReadAllLines(path).Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); + lines = File.ReadAllLines(path).Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); foreach (var key in lines) { diff --git a/Emby.Server.Implementations/Serialization/XmlSerializer.cs b/Emby.Server.Implementations/Serialization/XmlSerializer.cs index f7428eff72..6400ec16ec 100644 --- a/Emby.Server.Implementations/Serialization/XmlSerializer.cs +++ b/Emby.Server.Implementations/Serialization/XmlSerializer.cs @@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Serialization public object DeserializeFromFile(Type type, string file) { _logger.LogDebug("Deserializing file {0}", file); - using (var stream = _fileSystem.OpenRead(file)) + using (var stream = File.OpenRead(file)) { return DeserializeFromStream(type, stream); } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 93c8a3361e..6706e5700d 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -555,7 +555,7 @@ namespace Emby.Server.Implementations.Updates var packageChecksum = string.IsNullOrWhiteSpace(package.checksum) ? Guid.Empty : new Guid(package.checksum); if (!packageChecksum.Equals(Guid.Empty)) // support for legacy uploads for now { - using (var stream = _fileSystem.OpenRead(tempFile)) + using (var stream = File.OpenRead(tempFile)) { var check = Guid.Parse(BitConverter.ToString(_cryptographyProvider.ComputeMD5(stream)).Replace("-", string.Empty)); if (check != packageChecksum) @@ -571,7 +571,7 @@ namespace Emby.Server.Implementations.Updates try { Directory.CreateDirectory(Path.GetDirectoryName(target)); - _fileSystem.CopyFile(tempFile, target, true); + File.Copy(tempFile, target, true); //If it is an archive - write out a version file so we know what it is if (isArchive) { diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 552eda7201..5f33b7ad8e 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -220,7 +220,7 @@ namespace Jellyfin.Drawing.Skia var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + Path.GetExtension(path) ?? string.Empty); Directory.CreateDirectory(Path.GetDirectoryName(tempPath)); - fileSystem.CopyFile(path, tempPath, true); + File.Copy(path, tempPath, true); return tempPath; } diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index e40a55e567..38458e34c8 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -102,7 +102,7 @@ namespace MediaBrowser.LocalMetadata.Parsers { item.ResetPeople(); - using (var fileStream = FileSystem.OpenRead(metadataFile)) + using (var fileStream = File.OpenRead(metadataFile)) { using (var streamReader = new StreamReader(fileStream, encoding)) { diff --git a/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs b/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs index a1d925881c..6a5162b8d6 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs @@ -269,7 +269,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles var subLanguageId = NormalizeLanguage(request.Language); string hash; - using (var fileStream = _fileSystem.OpenRead(request.MediaPath)) + using (var fileStream = File.OpenRead(request.MediaPath)) { hash = Utilities.ComputeHash(fileStream); } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index ab92555e10..849548699b 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -210,7 +210,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } } - return _fileSystem.OpenRead(path); + return File.OpenRead(path); } private async Task GetReadableFile( @@ -672,7 +672,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles string text; Encoding encoding; - using (var fileStream = _fileSystem.OpenRead(file)) + using (var fileStream = File.OpenRead(file)) using (var reader = new StreamReader(fileStream, true)) { encoding = reader.CurrentEncoding; diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index c2e3dd1a17..40237bb968 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -70,7 +70,7 @@ namespace MediaBrowser.Providers.MediaInfo var tempFile = await _mediaEncoder.ExtractAudioImage(item.Path, imageStreamIndex, cancellationToken).ConfigureAwait(false); - _fileSystem.CopyFile(tempFile, path, true); + File.Copy(tempFile, path, true); try { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs index 5e9824ed1f..afc760dd4c 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -196,7 +197,7 @@ namespace MediaBrowser.Providers.MediaInfo private void FetchShortcutInfo(BaseItem item) { - item.ShortcutPath = _fileSystem.ReadAllLines(item.Path) + item.ShortcutPath = File.ReadAllLines(item.Path) .Select(NormalizeStrmLine) .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i) && !i.StartsWith("#", StringComparison.OrdinalIgnoreCase)); } diff --git a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs index 7a57adb335..dacb63f846 100644 --- a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs +++ b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs @@ -45,7 +45,7 @@ namespace MediaBrowser.Providers.Playlists return Task.FromResult(ItemUpdateType.None); } - using (var stream = _fileSystem.OpenRead(path)) + using (var stream = File.OpenRead(path)) { var items = GetItems(stream, extension).ToArray(); diff --git a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs index a8235fddce..4b41589f1c 100644 --- a/MediaBrowser.Providers/Studios/StudiosImageProvider.cs +++ b/MediaBrowser.Providers/Studios/StudiosImageProvider.cs @@ -155,7 +155,7 @@ namespace MediaBrowser.Providers.Studios try { - fileSystem.CopyFile(temp, file, true); + File.Copy(temp, file, true); } catch { diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index b6df64396c..c65fed440f 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -263,7 +263,7 @@ namespace MediaBrowser.Providers.TV if (!string.Equals(downloadLangaugeXmlFile, saveAsLanguageXmlFile, StringComparison.OrdinalIgnoreCase)) { - _fileSystem.CopyFile(downloadLangaugeXmlFile, saveAsLanguageXmlFile, true); + File.Copy(downloadLangaugeXmlFile, saveAsLanguageXmlFile, true); } await ExtractEpisodes(seriesDataPath, downloadLangaugeXmlFile, lastTvDbUpdateTime).ConfigureAwait(false); diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index de759492e6..2f4e21443b 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -443,7 +443,7 @@ namespace MediaBrowser.WebDashboard.Api //Copy all the files & Replaces any files with the same name foreach (var newPath in _fileSystem.GetFiles(source, true)) - _fileSystem.CopyFile(newPath.FullName, newPath.FullName.Replace(source, destination), true); + File.Copy(newPath.FullName, newPath.FullName.Replace(source, destination), true); } } diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 5132967454..f20dbbb6ea 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -108,7 +108,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers { if (!SupportsUrlAfterClosingXmlTag) { - using (var fileStream = FileSystem.OpenRead(metadataFile)) + using (var fileStream = File.OpenRead(metadataFile)) { using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { @@ -140,7 +140,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers return; } - using (var fileStream = FileSystem.OpenRead(metadataFile)) + using (var fileStream = File.OpenRead(metadataFile)) { using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { diff --git a/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs index c76f8345aa..a8cb6ac40d 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers protected override void Fetch(MetadataResult item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken) { - using (var fileStream = FileSystem.OpenRead(metadataFile)) + using (var fileStream = File.OpenRead(metadataFile)) { using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 2aacec6f05..96b906b3cd 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -974,7 +974,7 @@ namespace MediaBrowser.XbmcMetadata.Savers settings.IgnoreProcessingInstructions = true; settings.IgnoreComments = true; - using (var fileStream = fileSystem.OpenRead(path)) + using (var fileStream = File.OpenRead(path)) { using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { From 581a7fe078002785b9ba628ec139a42d678cdf25 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 22:59:53 +0100 Subject: [PATCH 17/27] Unwrapped `MoveDirectory`, `DirectoryExists`, `FileExists` & removed `MoveFile` --- BDInfo/BDROM.cs | 2 +- Emby.Drawing/ImageProcessor.cs | 4 ++-- Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs | 2 +- .../AppBase/BaseConfigurationManager.cs | 2 +- Emby.Server.Implementations/ApplicationHost.cs | 4 ++-- .../Collections/CollectionManager.cs | 2 +- .../ServerConfigurationManager.cs | 4 ++-- .../Devices/DeviceManager.cs | 2 +- .../FFMpeg/FFMpegLoader.cs | 4 ++-- .../IO/FileRefresher.cs | 2 +- .../IO/LibraryMonitor.cs | 2 +- .../Library/LibraryManager.cs | 14 +++++++------- .../LiveTv/EmbyTV/EmbyTV.cs | 18 +++++++++--------- .../LiveTv/Listings/XmlTvListingsProvider.cs | 4 ++-- .../Playlists/PlaylistManager.cs | 2 +- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 2 +- MediaBrowser.Api/EnvironmentService.cs | 6 +++--- MediaBrowser.Api/Images/ImageByNameService.cs | 18 +++++++++--------- MediaBrowser.Api/Images/RemoteImageService.cs | 2 +- MediaBrowser.Api/ItemLookupService.cs | 2 +- .../Library/LibraryStructureService.cs | 8 ++++---- .../Playback/BaseStreamingService.cs | 2 +- .../Playback/Hls/BaseHlsService.cs | 4 ++-- .../Playback/Hls/DynamicHlsService.cs | 8 ++++---- .../BaseProgressiveStreamingService.cs | 5 +++-- MediaBrowser.Controller/Entities/BaseItem.cs | 3 ++- MediaBrowser.Controller/Entities/User.cs | 6 +++--- .../MediaEncoding/EncodingHelper.cs | 4 ++-- .../EncodingConfigurationFactory.cs | 2 +- .../Encoder/BaseEncoder.cs | 2 +- .../Encoder/MediaEncoder.cs | 8 ++++---- .../Subtitles/SubtitleEncoder.cs | 10 +++++----- .../Manager/ItemImageProvider.cs | 2 +- .../Manager/ProviderManager.cs | 2 +- .../MediaInfo/AudioImageProvider.cs | 2 +- .../TV/MissingEpisodeProvider.cs | 2 +- .../TV/TheTVDB/TvdbSeriesProvider.cs | 6 +++--- .../Savers/SeasonNfoSaver.cs | 2 +- 38 files changed, 89 insertions(+), 87 deletions(-) diff --git a/BDInfo/BDROM.cs b/BDInfo/BDROM.cs index 85ea7b5773..4360ff1d42 100644 --- a/BDInfo/BDROM.cs +++ b/BDInfo/BDROM.cs @@ -150,7 +150,7 @@ namespace BDInfo Is3D = true; } - if (_fileSystem.FileExists(Path.Combine(DirectoryRoot.FullName, "FilmIndex.xml"))) + if (File.Exists(Path.Combine(DirectoryRoot.FullName, "FilmIndex.xml"))) { IsDBOX = true; } diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index c873802185..4901561ebc 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -244,7 +244,7 @@ namespace Emby.Drawing try { - if (!_fileSystem.FileExists(cacheFilePath)) + if (!File.Exists(cacheFilePath)) { if (options.CropWhiteSpace && !SupportsTransparency(originalImagePath)) { @@ -626,7 +626,7 @@ namespace Emby.Drawing try { // Check again in case of contention - if (_fileSystem.FileExists(enhancedImagePath)) + if (File.Exists(enhancedImagePath)) { return (enhancedImagePath, treatmentRequiresTransparency); } diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index a3ba6f7df8..c5564fd61f 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs @@ -214,7 +214,7 @@ namespace IsoMounter { string path = test.Trim(); - if (!string.IsNullOrEmpty(path) && FileSystem.FileExists(path = Path.Combine(path, name))) + if (!string.IsNullOrEmpty(path) && File.Exists(path = Path.Combine(path, name))) { return Path.GetFullPath(path); } diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index b9f0701a67..a921859941 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -197,7 +197,7 @@ namespace Emby.Server.Implementations.AppBase && !string.Equals(CommonConfiguration.CachePath ?? string.Empty, newPath)) { // Validate - if (!FileSystem.DirectoryExists(newPath)) + if (!Directory.Exists(newPath)) { throw new FileNotFoundException(string.Format("{0} does not exist.", newPath)); } diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 60cc19db70..454e266f78 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1008,7 +1008,7 @@ namespace Emby.Server.Implementations try { - if (!FileSystemManager.FileExists(certificateLocation)) + if (!File.Exists(certificateLocation)) { return null; } @@ -1434,7 +1434,7 @@ namespace Emby.Server.Implementations //if (generateCertificate) //{ - // if (!FileSystemManager.FileExists(certPath)) + // if (!File.Exists(certPath)) // { // FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath)); diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 1bed658167..c8b8229704 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -359,7 +359,7 @@ namespace Emby.Server.Implementations.Collections { var path = _collectionManager.GetCollectionsFolderPath(); - if (_fileSystem.DirectoryExists(path)) + if (Directory.Exists(path)) { try { diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs index ab2e1c9a96..18e279c2f0 100644 --- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -148,7 +148,7 @@ namespace Emby.Server.Implementations.Configuration && !string.Equals(Configuration.CertificatePath ?? string.Empty, newPath)) { // Validate - if (!FileSystem.FileExists(newPath)) + if (!File.Exists(newPath)) { throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", newPath)); } @@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.Configuration && !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath)) { // Validate - if (!FileSystem.DirectoryExists(newPath)) + if (!Directory.Exists(newPath)) { throw new FileNotFoundException(string.Format("{0} does not exist.", newPath)); } diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index 1958ae83b7..e94a649bfb 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -431,7 +431,7 @@ namespace Emby.Server.Implementations.Devices { var path = _deviceManager.GetUploadsPath(); - if (_fileSystem.DirectoryExists(path)) + if (Directory.Exists(path)) { try { diff --git a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs index cf12a8294e..79a42f294b 100644 --- a/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs +++ b/Emby.Server.Implementations/FFMpeg/FFMpegLoader.cs @@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.FFMpeg var prebuiltFolder = _appPaths.ProgramSystemPath; var prebuiltffmpeg = Path.Combine(prebuiltFolder, downloadInfo.FFMpegFilename); var prebuiltffprobe = Path.Combine(prebuiltFolder, downloadInfo.FFProbeFilename); - if (_fileSystem.FileExists(prebuiltffmpeg) && _fileSystem.FileExists(prebuiltffprobe)) + if (File.Exists(prebuiltffmpeg) && File.Exists(prebuiltffprobe)) { return new FFMpegInfo { @@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.FFMpeg var excludeFromDeletions = new List { versionedDirectoryPath }; - if (!_fileSystem.FileExists(info.ProbePath) || !_fileSystem.FileExists(info.EncoderPath)) + if (!File.Exists(info.ProbePath) || !File.Exists(info.EncoderPath)) { // ffmpeg not present. See if there's an older version we can start with var existingVersion = GetExistingVersion(info, rootEncoderPath); diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index af0c0a6a6c..12532a4971 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -195,7 +195,7 @@ namespace Emby.Server.Implementations.IO if (item != null) { // If the item has been deleted find the first valid parent that still exists - while (!_fileSystem.DirectoryExists(item.Path) && !_fileSystem.FileExists(item.Path)) + while (!Directory.Exists(item.Path) && !File.Exists(item.Path)) { item = item.GetOwner() ?? item.GetParent(); diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 45d8104f75..dad81c195c 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -277,7 +277,7 @@ namespace Emby.Server.Implementations.IO /// The path. private void StartWatchingPath(string path) { - if (!_fileSystem.DirectoryExists(path)) + if (!Directory.Exists(path)) { // Seeing a crash in the mono runtime due to an exception being thrown on a different thread Logger.LogInformation("Skipping realtime monitor for {0} because the path does not exist", path); diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 7b6372fe80..bf74048243 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -2863,7 +2863,7 @@ namespace Emby.Server.Implementations.Library var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; var virtualFolderPath = Path.Combine(rootFolderPath, name); - while (_fileSystem.DirectoryExists(virtualFolderPath)) + while (Directory.Exists(virtualFolderPath)) { name += "1"; virtualFolderPath = Path.Combine(rootFolderPath, name); @@ -2872,7 +2872,7 @@ namespace Emby.Server.Implementations.Library var mediaPathInfos = options.PathInfos; if (mediaPathInfos != null) { - var invalidpath = mediaPathInfos.FirstOrDefault(i => !_fileSystem.DirectoryExists(i.Path)); + var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path)); if (invalidpath != null) { throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + "."); @@ -2935,7 +2935,7 @@ namespace Emby.Server.Implementations.Library // // We can't validate protocol-based paths, so just allow them // if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) == -1) // { - // return _fileSystem.DirectoryExists(path); + // return Directory.Exists(path); // } //} @@ -2963,7 +2963,7 @@ namespace Emby.Server.Implementations.Library throw new ArgumentNullException(nameof(path)); } - if (!_fileSystem.DirectoryExists(path)) + if (!Directory.Exists(path)) { throw new FileNotFoundException("The path does not exist."); } @@ -2980,7 +2980,7 @@ namespace Emby.Server.Implementations.Library var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension); - while (_fileSystem.FileExists(lnk)) + while (File.Exists(lnk)) { shortcutFilename += "1"; lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension); @@ -3073,7 +3073,7 @@ namespace Emby.Server.Implementations.Library var path = Path.Combine(rootFolderPath, name); - if (!_fileSystem.DirectoryExists(path)) + if (!Directory.Exists(path)) { throw new FileNotFoundException("The media folder does not exist"); } @@ -3145,7 +3145,7 @@ namespace Emby.Server.Implementations.Library var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName); - if (!_fileSystem.DirectoryExists(virtualFolderPath)) + if (!Directory.Exists(virtualFolderPath)) { throw new FileNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName)); } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 762509e749..6a2a46c9f7 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1427,7 +1427,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV timer.RetryCount++; _timerProvider.AddOrUpdate(timer); } - else if (_fileSystem.FileExists(recordPath)) + else if (File.Exists(recordPath)) { timer.RecordingPath = recordPath; timer.Status = RecordingStatus.Completed; @@ -1573,7 +1573,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV .Where(i => i.Status == RecordingStatus.Completed && !string.IsNullOrWhiteSpace(i.RecordingPath)) .Where(i => string.Equals(i.SeriesTimerId, seriesTimerId, StringComparison.OrdinalIgnoreCase)) .OrderByDescending(i => i.EndDate) - .Where(i => _fileSystem.FileExists(i.RecordingPath)) + .Where(i => File.Exists(i.RecordingPath)) .Skip(seriesTimer.KeepUpTo - 1) .ToList(); @@ -1595,7 +1595,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV DtoOptions = new DtoOptions(true) })) - .Where(i => i.IsFileProtocol && _fileSystem.FileExists(i.Path)) + .Where(i => i.IsFileProtocol && File.Exists(i.Path)) .Skip(seriesTimer.KeepUpTo - 1) .ToList(); @@ -1689,7 +1689,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private bool FileExists(string path, string timerId) { - if (_fileSystem.FileExists(path)) + if (File.Exists(path)) { return true; } @@ -1961,7 +1961,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var nfoPath = Path.Combine(seriesPath, "tvshow.nfo"); - if (_fileSystem.FileExists(nfoPath)) + if (File.Exists(nfoPath)) { return; } @@ -2023,7 +2023,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var nfoPath = Path.ChangeExtension(recordingPath, ".nfo"); - if (_fileSystem.FileExists(nfoPath)) + if (File.Exists(nfoPath)) { return; } @@ -2688,7 +2688,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var defaultFolder = RecordingPath; var defaultName = "Recordings"; - if (_fileSystem.DirectoryExists(defaultFolder)) + if (Directory.Exists(defaultFolder)) { list.Add(new VirtualFolderInfo { @@ -2698,7 +2698,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } var customPath = GetConfiguration().MovieRecordingPath; - if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && _fileSystem.DirectoryExists(customPath)) + if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && Directory.Exists(customPath)) { list.Add(new VirtualFolderInfo { @@ -2709,7 +2709,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } customPath = GetConfiguration().SeriesRecordingPath; - if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && _fileSystem.DirectoryExists(customPath)) + if ((!string.IsNullOrWhiteSpace(customPath) && !string.Equals(customPath, defaultFolder, StringComparison.OrdinalIgnoreCase)) && Directory.Exists(customPath)) { list.Add(new VirtualFolderInfo { diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index dccff65439..f152ac4652 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -61,7 +61,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings string cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml"; string cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename); - if (_fileSystem.FileExists(cacheFile)) + if (File.Exists(cacheFile)) { return UnzipIfNeeded(path, cacheFile); } @@ -255,7 +255,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) { // Assume all urls are valid. check files for existence - if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !_fileSystem.FileExists(info.Path)) + if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !File.Exists(info.Path)) { throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path); } diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 32be5648d5..6b8afcb7f2 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.Playlists private string GetTargetPath(string path) { - while (_fileSystem.DirectoryExists(path)) + while (Directory.Exists(path)) { path += "1"; } diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 5f33b7ad8e..f1b886ec64 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -257,7 +257,7 @@ namespace Jellyfin.Drawing.Skia internal static SKBitmap Decode(string path, bool forceCleanBitmap, IFileSystem fileSystem, ImageOrientation? orientation, out SKEncodedOrigin origin) { - if (!fileSystem.FileExists(path)) + if (!File.Exists(path)) { throw new FileNotFoundException("File not found", path); } diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index 366e9308eb..57e3da7ff6 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -137,14 +137,14 @@ namespace MediaBrowser.Api { if (request.IsFile.Value) { - if (!_fileSystem.FileExists(request.Path)) + if (!File.Exists(request.Path)) { throw new FileNotFoundException("File not found", request.Path); } } else { - if (!_fileSystem.DirectoryExists(request.Path)) + if (Directory.Exists(request.Path)) { throw new FileNotFoundException("File not found", request.Path); } @@ -153,7 +153,7 @@ namespace MediaBrowser.Api else { - if (!_fileSystem.FileExists(request.Path) && !_fileSystem.DirectoryExists(request.Path)) + if (!File.Exists(request.Path) && Directory.Exists(request.Path)) { throw new FileNotFoundException("Path not found", request.Path); } diff --git a/MediaBrowser.Api/Images/ImageByNameService.cs b/MediaBrowser.Api/Images/ImageByNameService.cs index 3ac576b0f2..fdf5842772 100644 --- a/MediaBrowser.Api/Images/ImageByNameService.cs +++ b/MediaBrowser.Api/Images/ImageByNameService.cs @@ -185,7 +185,7 @@ namespace MediaBrowser.Api.Images var paths = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(_appPaths.GeneralPath, request.Name, filename + i)).ToList(); - var path = paths.FirstOrDefault(_fileSystem.FileExists) ?? paths.FirstOrDefault(); + var path = paths.FirstOrDefault(File.Exists) ?? paths.FirstOrDefault(); return _resultFactory.GetStaticFileResult(Request, path); } @@ -199,11 +199,11 @@ namespace MediaBrowser.Api.Images { var themeFolder = Path.Combine(_appPaths.RatingsPath, request.Theme); - if (_fileSystem.DirectoryExists(themeFolder)) + if (Directory.Exists(themeFolder)) { var path = BaseItem.SupportedImageExtensions .Select(i => Path.Combine(themeFolder, request.Name + i)) - .FirstOrDefault(_fileSystem.FileExists); + .FirstOrDefault(File.Exists); if (!string.IsNullOrEmpty(path)) { @@ -213,14 +213,14 @@ namespace MediaBrowser.Api.Images var allFolder = Path.Combine(_appPaths.RatingsPath, "all"); - if (_fileSystem.DirectoryExists(allFolder)) + if (Directory.Exists(allFolder)) { // Avoid implicitly captured closure var currentRequest = request; var path = BaseItem.SupportedImageExtensions .Select(i => Path.Combine(allFolder, currentRequest.Name + i)) - .FirstOrDefault(_fileSystem.FileExists); + .FirstOrDefault(File.Exists); if (!string.IsNullOrEmpty(path)) { @@ -240,10 +240,10 @@ namespace MediaBrowser.Api.Images { var themeFolder = Path.Combine(_appPaths.MediaInfoImagesPath, request.Theme); - if (_fileSystem.DirectoryExists(themeFolder)) + if (Directory.Exists(themeFolder)) { var path = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(themeFolder, request.Name + i)) - .FirstOrDefault(_fileSystem.FileExists); + .FirstOrDefault(File.Exists); if (!string.IsNullOrEmpty(path)) { @@ -253,13 +253,13 @@ namespace MediaBrowser.Api.Images var allFolder = Path.Combine(_appPaths.MediaInfoImagesPath, "all"); - if (_fileSystem.DirectoryExists(allFolder)) + if (Directory.Exists(allFolder)) { // Avoid implicitly captured closure var currentRequest = request; var path = BaseItem.SupportedImageExtensions.Select(i => Path.Combine(allFolder, currentRequest.Name + i)) - .FirstOrDefault(_fileSystem.FileExists); + .FirstOrDefault(File.Exists); if (!string.IsNullOrEmpty(path)) { diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 3a1ebced52..49b382e343 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -222,7 +222,7 @@ namespace MediaBrowser.Api.Images { contentPath = _fileSystem.ReadAllText(pointerCachePath); - if (_fileSystem.FileExists(contentPath)) + if (File.Exists(contentPath)) { return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false); } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index eaf2d1e1b0..ae3f280e80 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -267,7 +267,7 @@ namespace MediaBrowser.Api { contentPath = _fileSystem.ReadAllText(pointerCachePath); - if (_fileSystem.FileExists(contentPath)) + if (File.Exists(contentPath)) { return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false); } diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index 3be6b29dde..c95a068051 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -255,12 +255,12 @@ namespace MediaBrowser.Api.Library var currentPath = Path.Combine(rootFolderPath, request.Name); var newPath = Path.Combine(rootFolderPath, request.NewName); - if (!_fileSystem.DirectoryExists(currentPath)) + if (Directory.Exists(currentPath)) { throw new FileNotFoundException("The media collection does not exist"); } - if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && _fileSystem.DirectoryExists(newPath)) + if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath)) { throw new ArgumentException("Media library already exists at " + newPath + "."); } @@ -273,11 +273,11 @@ namespace MediaBrowser.Api.Library if (string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase)) { var tempPath = Path.Combine(rootFolderPath, Guid.NewGuid().ToString("N")); - _fileSystem.MoveDirectory(currentPath, tempPath); + Directory.Move(currentPath, tempPath); currentPath = tempPath; } - _fileSystem.MoveDirectory(currentPath, newPath); + Directory.Move(currentPath, newPath); } finally { diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 07e84536fc..4ed83baadb 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -290,7 +290,7 @@ namespace MediaBrowser.Api.Playback new JobLogger(Logger).StartStreamingLog(state, process.StandardError.BaseStream, state.LogFileStream); // Wait for the file to exist before proceeeding - while (!FileSystem.FileExists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited) + while (!File.Exists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited) { await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false); } diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 3c41226d0c..08a2183f83 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -83,13 +83,13 @@ namespace MediaBrowser.Api.Playback.Hls TranscodingJob job = null; var playlist = state.OutputFilePath; - if (!FileSystem.FileExists(playlist)) + if (!File.Exists(playlist)) { var transcodingLock = ApiEntryPoint.Instance.GetTranscodingLock(playlist); await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false); try { - if (!FileSystem.FileExists(playlist)) + if (!File.Exists(playlist)) { // If the playlist doesn't already exist, startup ffmpeg try diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index c30ad67ecd..0a3633178a 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -164,7 +164,7 @@ namespace MediaBrowser.Api.Playback.Hls TranscodingJob job = null; - if (FileSystem.FileExists(segmentPath)) + if (File.Exists(segmentPath)) { job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, requestedIndex, job, cancellationToken).ConfigureAwait(false); @@ -177,7 +177,7 @@ namespace MediaBrowser.Api.Playback.Hls try { - if (FileSystem.FileExists(segmentPath)) + if (File.Exists(segmentPath)) { job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); transcodingLock.Release(); @@ -433,7 +433,7 @@ namespace MediaBrowser.Api.Playback.Hls TranscodingJob transcodingJob, CancellationToken cancellationToken) { - var segmentFileExists = FileSystem.FileExists(segmentPath); + var segmentFileExists = File.Exists(segmentPath); // If all transcoding has completed, just return immediately if (transcodingJob != null && transcodingJob.HasExited && segmentFileExists) @@ -465,7 +465,7 @@ namespace MediaBrowser.Api.Playback.Hls { if (!segmentFileExists) { - segmentFileExists = FileSystem.FileExists(segmentPath); + segmentFileExists = File.Exists(segmentPath); } if (segmentFileExists) { diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index bb21fe5ae1..621d1ff88d 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Net; @@ -153,7 +154,7 @@ namespace MediaBrowser.Api.Playback.Progressive } var outputPath = state.OutputFilePath; - var outputPathExists = FileSystem.FileExists(outputPath); + var outputPathExists = File.Exists(outputPath); var transcodingJob = ApiEntryPoint.Instance.GetTranscodingJob(outputPath, TranscodingJobType.Progressive); var isTranscodeCached = outputPathExists && transcodingJob != null; @@ -377,7 +378,7 @@ namespace MediaBrowser.Api.Playback.Progressive { TranscodingJob job; - if (!FileSystem.FileExists(outputPath)) + if (!File.Exists(outputPath)) { job = await StartFfMpeg(state, outputPath, cancellationTokenSource).ConfigureAwait(false); } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 096cc7016e..ab9458187d 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; using System.Text; using System.Threading; @@ -2343,7 +2344,7 @@ namespace MediaBrowser.Controller.Entities var newImagePaths = images.Select(i => i.FullName).ToList(); var deleted = existingImages - .Where(i => i.IsLocalFile && !newImagePaths.Contains(i.Path, StringComparer.OrdinalIgnoreCase) && !FileSystem.FileExists(i.Path)) + .Where(i => i.IsLocalFile && !newImagePaths.Contains(i.Path, StringComparer.OrdinalIgnoreCase) && !File.Exists(i.Path)) .ToList(); if (deleted.Count > 0) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index ea2ea9a506..06bae92112 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -168,14 +168,14 @@ namespace MediaBrowser.Controller.Entities var oldConfigurationDirectory = ConfigurationDirectoryPath; // Exceptions will be thrown if these paths already exist - if (FileSystem.DirectoryExists(newConfigDirectory)) + if (Directory.Exists(newConfigDirectory)) { Directory.Delete(newConfigDirectory, true); } - if (FileSystem.DirectoryExists(oldConfigurationDirectory)) + if (Directory.Exists(oldConfigurationDirectory)) { - FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); + Directory.Move(oldConfigurationDirectory, newConfigDirectory); } else { diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 968e3dbcb5..fc2b8f9c9b 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -434,7 +434,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase)) { var idxFile = Path.ChangeExtension(subtitlePath, ".idx"); - if (_fileSystem.FileExists(idxFile)) + if (File.Exists(idxFile)) { subtitlePath = idxFile; } @@ -542,7 +542,7 @@ namespace MediaBrowser.Controller.MediaEncoding // var fallbackFontPath = Path.Combine(_appPaths.ProgramDataPath, "fonts", "DroidSansFallback.ttf"); // string fallbackFontParam = string.Empty; - // if (!_fileSystem.FileExists(fallbackFontPath)) + // if (!File.Exists(fallbackFontPath)) // { // _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fallbackFontPath)); // using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), GetType().Namespace + ".DroidSansFallback.ttf")) diff --git a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs index 1af4146bc8..c20d73dc73 100644 --- a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs +++ b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.MediaEncoding.Configuration && !string.Equals(oldEncodingConfig.TranscodingTempPath ?? string.Empty, newPath)) { // Validate - if (!_fileSystem.DirectoryExists(newPath)) + if (Directory.Exists(newPath)) { throw new FileNotFoundException(string.Format("{0} does not exist.", newPath)); } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 2d43b82562..d3c44f5ebe 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -137,7 +137,7 @@ namespace MediaBrowser.MediaEncoding.Encoder new JobLogger(Logger).StartStreamingLog(encodingJob, process.StandardError.BaseStream, encodingJob.LogFileStream); // Wait for the file to exist before proceeeding - while (!FileSystem.FileExists(encodingJob.OutputFilePath) && !encodingJob.HasExited) + while (!File.Exists(encodingJob.OutputFilePath) && !encodingJob.HasExited) { await Task.Delay(100, cancellationToken).ConfigureAwait(false); } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 92e091dc0a..7bcb1e38af 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -214,7 +214,7 @@ namespace MediaBrowser.MediaEncoding.Encoder throw new ArgumentNullException(nameof(path)); } - if (!FileSystem.FileExists(path) && !FileSystem.DirectoryExists(path)) + if (!File.Exists(path) && Directory.Exists(path)) { throw new ResourceNotFoundException(); } @@ -288,12 +288,12 @@ namespace MediaBrowser.MediaEncoding.Encoder if (!string.IsNullOrWhiteSpace(appPath)) { - if (FileSystem.DirectoryExists(appPath)) + if (Directory.Exists(appPath)) { return GetPathsFromDirectory(appPath); } - if (FileSystem.FileExists(appPath)) + if (File.Exists(appPath)) { return new Tuple(appPath, GetProbePathFromEncoderPath(appPath)); } @@ -336,7 +336,7 @@ namespace MediaBrowser.MediaEncoding.Encoder var ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); var ffprobePath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); - if (string.IsNullOrWhiteSpace(ffmpegPath) || !FileSystem.FileExists(ffmpegPath)) + if (string.IsNullOrWhiteSpace(ffmpegPath) || !File.Exists(ffmpegPath)) { files = FileSystem.GetFilePaths(path, true); diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 849548699b..eb62b2b8f1 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -386,7 +386,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles try { - if (!_fileSystem.FileExists(outputPath)) + if (!File.Exists(outputPath)) { await ConvertTextSubtitleToSrtInternal(inputPath, language, inputProtocol, outputPath, cancellationToken).ConfigureAwait(false); } @@ -481,7 +481,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { failed = true; - if (_fileSystem.FileExists(outputPath)) + if (File.Exists(outputPath)) { try { @@ -494,7 +494,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } } } - else if (!_fileSystem.FileExists(outputPath)) + else if (!File.Exists(outputPath)) { failed = true; } @@ -537,7 +537,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles try { - if (!_fileSystem.FileExists(outputPath)) + if (!File.Exists(outputPath)) { await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex, outputCodec, outputPath, cancellationToken).ConfigureAwait(false); } @@ -634,7 +634,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles _logger.LogError(ex, "Error deleting extracted subtitle {Path}", outputPath); } } - else if (!_fileSystem.FileExists(outputPath)) + else if (!File.Exists(outputPath)) { failed = true; } diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index c2e53ae6c4..493c97b6ec 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -387,7 +387,7 @@ namespace MediaBrowser.Providers.Manager var existing = item.GetImageInfo(type, 0); if (existing != null) { - if (existing.IsLocalFile && !_fileSystem.FileExists(existing.Path)) + if (existing.IsLocalFile && !File.Exists(existing.Path)) { item.RemoveImage(existing); changed = true; diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 65364ad679..eda5163f00 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -703,7 +703,7 @@ namespace MediaBrowser.Providers.Manager // Manual edit occurred // Even if save local is off, save locally anyway if the metadata file already exists - if (fileSaver == null || !_fileSystem.FileExists(fileSaver.GetSavePath(item))) + if (fileSaver == null || !File.Exists(fileSaver.GetSavePath(item))) { return false; } diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index 40237bb968..61a8a122b9 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.Providers.MediaInfo { var path = GetAudioImagePath(item); - if (!_fileSystem.FileExists(path)) + if (!File.Exists(path)) { Directory.CreateDirectory(Path.GetDirectoryName(path)); diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 8da6d45230..fcdea33d01 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.Providers.TV } // Check this in order to avoid logging an exception due to directory not existing - if (!_fileSystem.DirectoryExists(seriesDataPath)) + if (Directory.Exists(seriesDataPath)) { return false; } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index c65fed440f..496e0bb72d 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -1526,7 +1526,7 @@ namespace MediaBrowser.Providers.TV var file = Path.Combine(seriesDataPath, string.Format("episode-{0}-{1}.xml", seasonNumber, episodeNumber)); // Only save the file if not already there, or if the episode has changed - if (hasEpisodeChanged || !_fileSystem.FileExists(file)) + if (hasEpisodeChanged || !File.Exists(file)) { using (var fileStream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true)) { @@ -1546,7 +1546,7 @@ namespace MediaBrowser.Providers.TV file = Path.Combine(seriesDataPath, string.Format("episode-abs-{0}.xml", absoluteNumber)); // Only save the file if not already there, or if the episode has changed - if (hasEpisodeChanged || !_fileSystem.FileExists(file)) + if (hasEpisodeChanged || !File.Exists(file)) { using (var fileStream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true)) { @@ -1567,7 +1567,7 @@ namespace MediaBrowser.Providers.TV file = Path.Combine(seriesDataPath, string.Format("episode-dvd-{0}-{1}.xml", dvdSeasonNumber, dvdEpisodeNumber)); // Only save the file if not already there, or if the episode has changed - if (hasEpisodeChanged || !_fileSystem.FileExists(file)) + if (hasEpisodeChanged || !File.Exists(file)) { using (var fileStream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true)) { diff --git a/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs index 102fba70b4..5246bec023 100644 --- a/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/SeasonNfoSaver.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.XbmcMetadata.Savers return false; } - return updateType >= MinimumUpdateType || (updateType >= ItemUpdateType.MetadataImport && FileSystem.FileExists(GetSavePath(item))); + return updateType >= MinimumUpdateType || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSavePath(item))); } protected override void WriteCustomElements(BaseItem item, XmlWriter writer) From b9a111432a8c85cd6cd2bb6c80ba3acd8a27409d Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 23:09:07 +0100 Subject: [PATCH 18/27] Unwrapped all /(Write|Read)All(Text|Bytes)/ functions. --- .../AppBase/BaseConfigurationManager.cs | 3 ++- .../AppBase/ConfigurationHelper.cs | 4 ++-- Emby.Server.Implementations/Devices/DeviceId.cs | 2 +- .../IO/MbLinkShortcutHandler.cs | 4 ++-- .../Library/LibraryManager.cs | 2 +- .../Library/UserManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 15 ++++++++++----- .../ResourceFileManager.cs | 2 +- .../ScheduledTasks/ChapterImagesTask.cs | 5 +++-- .../Updates/InstallationManager.cs | 2 +- MediaBrowser.Api/EnvironmentService.cs | 2 +- MediaBrowser.Api/Images/RemoteImageService.cs | 6 +++--- MediaBrowser.Api/ItemLookupService.cs | 6 +++--- .../Playback/Hls/DynamicHlsService.cs | 2 +- .../Subtitles/SubtitleEncoder.cs | 2 +- .../TV/TheTVDB/TvdbEpisodeProvider.cs | 2 +- .../TV/TheTVDB/TvdbPrescanTask.cs | 4 ++-- 17 files changed, 36 insertions(+), 29 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index a921859941..ec3ca8ead1 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -210,7 +210,8 @@ namespace Emby.Server.Implementations.AppBase { var file = Path.Combine(path, Guid.NewGuid().ToString()); - FileSystem.WriteAllText(file, string.Empty); + string text = string.Empty; + File.WriteAllText(file, text); FileSystem.DeleteFile(file); } diff --git a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs index b9af663a95..3faad76e7d 100644 --- a/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs +++ b/Emby.Server.Implementations/AppBase/ConfigurationHelper.cs @@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.AppBase // Use try/catch to avoid the extra file system lookup using File.Exists try { - buffer = fileSystem.ReadAllBytes(path); + buffer = File.ReadAllBytes(path); configuration = xmlSerializer.DeserializeFromBytes(type, buffer); } @@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.AppBase Directory.CreateDirectory(Path.GetDirectoryName(path)); // Save it after load in case we got new items - fileSystem.WriteAllBytes(path, newBytes); + File.WriteAllBytes(path, newBytes); } return configuration; diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 9640e7abb1..866bd137ff 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Devices lock (_syncLock) { - _fileSystem.WriteAllText(path, id, Encoding.UTF8); + File.WriteAllText(path, id, Encoding.UTF8); } } catch (Exception ex) diff --git a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs index a306f94b36..5e5e91bb39 100644 --- a/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs +++ b/Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs @@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.IO if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase)) { - var path = _fileSystem.ReadAllText(shortcutPath); + var path = File.ReadAllText(shortcutPath); return _fileSystem.NormalizePath(path); } @@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.IO throw new ArgumentNullException(nameof(targetPath)); } - _fileSystem.WriteAllText(shortcutPath, targetPath); + File.WriteAllText(shortcutPath, targetPath); } } } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index bf74048243..f96a211ec5 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -2889,7 +2889,7 @@ namespace Emby.Server.Implementations.Library { var path = Path.Combine(virtualFolderPath, collectionType + ".collection"); - _fileSystem.WriteAllBytes(path, Array.Empty()); + File.WriteAllBytes(path, Array.Empty()); } CollectionFolder.SaveLibraryOptions(virtualFolderPath, options); diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 0b87455a43..05fce4542f 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -904,7 +904,7 @@ namespace Emby.Server.Implementations.Library // Tuesday, 22 August 2006 06:30 AM text.AppendLine("The pin code will expire at " + localExpirationTime.ToString("f1", CultureInfo.CurrentCulture)); - _fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8); + File.WriteAllText(path, text.ToString(), Encoding.UTF8); var result = new PasswordPinCreationResult { diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 6b8afcb7f2..29836e0bff 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -340,7 +340,8 @@ namespace Emby.Server.Implementations.Playlists playlist.PlaylistEntries.Add(entry); } - _fileSystem.WriteAllText(playlistPath, new WplContent().ToText(playlist)); + string text = new WplContent().ToText(playlist); + File.WriteAllText(playlistPath, text); } if (string.Equals(".zpl", extension, StringComparison.OrdinalIgnoreCase)) { @@ -373,7 +374,8 @@ namespace Emby.Server.Implementations.Playlists playlist.PlaylistEntries.Add(entry); } - _fileSystem.WriteAllText(playlistPath, new ZplContent().ToText(playlist)); + string text = new ZplContent().ToText(playlist); + File.WriteAllText(playlistPath, text); } if (string.Equals(".m3u", extension, StringComparison.OrdinalIgnoreCase)) { @@ -401,7 +403,8 @@ namespace Emby.Server.Implementations.Playlists playlist.PlaylistEntries.Add(entry); } - _fileSystem.WriteAllText(playlistPath, new M3uContent().ToText(playlist)); + string text = new M3uContent().ToText(playlist); + File.WriteAllText(playlistPath, text); } if (string.Equals(".m3u8", extension, StringComparison.OrdinalIgnoreCase)) { @@ -429,7 +432,8 @@ namespace Emby.Server.Implementations.Playlists playlist.PlaylistEntries.Add(entry); } - _fileSystem.WriteAllText(playlistPath, new M3u8Content().ToText(playlist)); + string text = new M3u8Content().ToText(playlist); + File.WriteAllText(playlistPath, text); } if (string.Equals(".pls", extension, StringComparison.OrdinalIgnoreCase)) { @@ -449,7 +453,8 @@ namespace Emby.Server.Implementations.Playlists playlist.PlaylistEntries.Add(entry); } - _fileSystem.WriteAllText(playlistPath, new PlsContent().ToText(playlist)); + string text = new PlsContent().ToText(playlist); + File.WriteAllText(playlistPath, text); } } diff --git a/Emby.Server.Implementations/ResourceFileManager.cs b/Emby.Server.Implementations/ResourceFileManager.cs index 8c1f765e27..890d848f4b 100644 --- a/Emby.Server.Implementations/ResourceFileManager.cs +++ b/Emby.Server.Implementations/ResourceFileManager.cs @@ -37,7 +37,7 @@ namespace Emby.Server.Implementations public string ReadAllText(string basePath, string virtualPath) { - return _fileSystem.ReadAllText(GetResourcePath(basePath, virtualPath)); + return File.ReadAllText(GetResourcePath(basePath, virtualPath)); } private string GetResourcePath(string basePath, string virtualPath) diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index 4124063f07..c31bdd13d2 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { try { - previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath) + previouslyFailedImages = File.ReadAllText(failHistoryPath) .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } @@ -143,7 +143,8 @@ namespace Emby.Server.Implementations.ScheduledTasks Directory.CreateDirectory(parentPath); - _fileSystem.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray())); + string text = string.Join("|", previouslyFailedImages.ToArray()); + File.WriteAllText(failHistoryPath, text); } numComplete++; diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 6706e5700d..5521556356 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -575,7 +575,7 @@ namespace Emby.Server.Implementations.Updates //If it is an archive - write out a version file so we know what it is if (isArchive) { - _fileSystem.WriteAllText(target + ".ver", package.versionStr); + File.WriteAllText(target + ".ver", package.versionStr); } } catch (IOException ex) diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index 57e3da7ff6..907c44fe1d 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -169,7 +169,7 @@ namespace MediaBrowser.Api { var file = Path.Combine(path, Guid.NewGuid().ToString()); - _fileSystem.WriteAllText(file, string.Empty); + File.WriteAllText(file, string.Empty); _fileSystem.DeleteFile(file); } diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 49b382e343..24d4751c59 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -220,7 +220,7 @@ namespace MediaBrowser.Api.Images try { - contentPath = _fileSystem.ReadAllText(pointerCachePath); + contentPath = File.ReadAllText(pointerCachePath); if (File.Exists(contentPath)) { @@ -239,7 +239,7 @@ namespace MediaBrowser.Api.Images await DownloadImage(request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false); // Read the pointer file again - contentPath = _fileSystem.ReadAllText(pointerCachePath); + contentPath = File.ReadAllText(pointerCachePath); return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false); } @@ -274,7 +274,7 @@ namespace MediaBrowser.Api.Images } Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); - _fileSystem.WriteAllText(pointerCachePath, fullCachePath); + File.WriteAllText(pointerCachePath, fullCachePath); } } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index ae3f280e80..0e7bdc0860 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -265,7 +265,7 @@ namespace MediaBrowser.Api try { - contentPath = _fileSystem.ReadAllText(pointerCachePath); + contentPath = File.ReadAllText(pointerCachePath); if (File.Exists(contentPath)) { @@ -284,7 +284,7 @@ namespace MediaBrowser.Api await DownloadImage(request.ProviderName, request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false); // Read the pointer file again - contentPath = _fileSystem.ReadAllText(pointerCachePath); + contentPath = File.ReadAllText(pointerCachePath); return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false); } @@ -315,7 +315,7 @@ namespace MediaBrowser.Api } Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); - _fileSystem.WriteAllText(pointerCachePath, fullCachePath); + File.WriteAllText(pointerCachePath, fullCachePath); } /// diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 0a3633178a..30696ec979 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -458,7 +458,7 @@ namespace MediaBrowser.Api.Playback.Hls { try { - var text = FileSystem.ReadAllText(playlistPath, Encoding.UTF8); + var text = File.ReadAllText(playlistPath, Encoding.UTF8); // If it appears in the playlist, it's done if (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1) diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index eb62b2b8f1..d978359c71 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -747,7 +747,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } if (protocol == MediaProtocol.File) { - return _fileSystem.ReadAllBytes(path); + return File.ReadAllBytes(path); } throw new ArgumentOutOfRangeException(nameof(protocol)); diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index 7e2d54b903..25fc214b54 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -296,7 +296,7 @@ namespace MediaBrowser.Providers.TV private XmlReader GetXmlReader(FileSystemMetadata xmlFile) { - return GetXmlReader(_fileSystem.ReadAllText(xmlFile.FullName, Encoding.UTF8)); + return GetXmlReader(File.ReadAllText(xmlFile.FullName, Encoding.UTF8)); } private XmlReader GetXmlReader(string xml) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs index fc75e2c0af..6f7cb72d33 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs @@ -95,7 +95,7 @@ namespace MediaBrowser.Providers.TV } // Find out the last time we queried tvdb for updates - var lastUpdateTime = timestampFileInfo.Exists ? _fileSystem.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty; + var lastUpdateTime = timestampFileInfo.Exists ? File.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty; string newUpdateTime; @@ -171,7 +171,7 @@ namespace MediaBrowser.Providers.TV await UpdateSeries(listToUpdate, path, nullableUpdateValue, progress, cancellationToken).ConfigureAwait(false); } - _fileSystem.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8); + File.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8); progress.Report(100); } From 450f246f959f55bdc0b63f78141e7397891c4210 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 23:23:43 +0100 Subject: [PATCH 19/27] Unwrapped `GetFileNameWithoutExtension` --- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- .../Images/EpisodeLocalImageProvider.cs | 2 +- MediaBrowser.Providers/Manager/ImageSaver.cs | 8 ++++---- MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs | 4 ++-- MediaBrowser.Providers/Subtitles/SubtitleManager.cs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index ab9458187d..34ae446c70 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -2509,7 +2509,7 @@ namespace MediaBrowser.Controller.Entities if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path)) { - Name = FileSystem.GetFileNameWithoutExtension(Path); + Name = System.IO.Path.GetFileNameWithoutExtension(Path); hasChanges = true; } diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 16f280982d..443f3fbb5e 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -34,7 +34,7 @@ namespace MediaBrowser.LocalMetadata.Images var parentPathFiles = directoryService.GetFiles(parentPath); - var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path); + var nameWithoutExtension = Path.GetFileNameWithoutExtension(item.Path); return GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles); } diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index 802e02f78a..dee4733746 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -411,7 +411,7 @@ namespace MediaBrowser.Providers.Manager filename = item is MusicAlbum ? "cdart" : "disc"; break; case ImageType.Primary: - filename = saveLocally && item is Episode ? _fileSystem.GetFileNameWithoutExtension(item.Path) : folderName; + filename = saveLocally && item is Episode ? Path.GetFileNameWithoutExtension(item.Path) : folderName; break; case ImageType.Backdrop: filename = GetBackdropSaveFilename(item.GetImages(type), "backdrop", "backdrop", imageIndex); @@ -471,7 +471,7 @@ namespace MediaBrowser.Providers.Manager return zeroIndexFilename; } - var filenames = images.Select(i => _fileSystem.GetFileNameWithoutExtension(i.Path)).ToList(); + var filenames = images.Select(i => Path.GetFileNameWithoutExtension(i.Path)).ToList(); var current = 1; while (filenames.Contains(numberedIndexPrefix + current.ToString(UsCulture), StringComparer.OrdinalIgnoreCase)) @@ -571,7 +571,7 @@ namespace MediaBrowser.Providers.Manager { var seasonFolder = Path.GetDirectoryName(item.Path); - var imageFilename = _fileSystem.GetFileNameWithoutExtension(item.Path) + "-thumb" + extension; + var imageFilename = Path.GetFileNameWithoutExtension(item.Path) + "-thumb" + extension; return new[] { Path.Combine(seasonFolder, imageFilename) }; } @@ -619,7 +619,7 @@ namespace MediaBrowser.Providers.Manager } var folder = Path.GetDirectoryName(item.Path); - return Path.Combine(folder, _fileSystem.GetFileNameWithoutExtension(item.Path) + "-" + imageFilename + extension); + return Path.Combine(folder, Path.GetFileNameWithoutExtension(item.Path) + "-" + imageFilename + extension); } } } diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs b/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs index 2ce10b656a..b6f862f9a8 100644 --- a/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs +++ b/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs @@ -98,7 +98,7 @@ namespace MediaBrowser.Providers.MediaInfo int startIndex, string[] files) { - var videoFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(videoPath); + var videoFileNameWithoutExtension = Path.GetFileNameWithoutExtension(videoPath); videoFileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(videoFileNameWithoutExtension); foreach (var fullName in files) @@ -110,7 +110,7 @@ namespace MediaBrowser.Providers.MediaInfo continue; } - var fileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(fullName); + var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullName); fileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(fileNameWithoutExtension); if (!string.Equals(videoFileNameWithoutExtension, fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase) && diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 4cec8b4a97..138794b7cf 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -168,7 +168,7 @@ namespace MediaBrowser.Providers.Subtitles memoryStream.Position = 0; var savePaths = new List(); - var saveFileName = _fileSystem.GetFileNameWithoutExtension(video.Path) + "." + response.Language.ToLower(); + var saveFileName = Path.GetFileNameWithoutExtension(video.Path) + "." + response.Language.ToLower(); if (response.IsForced) { From d3afa531913d94e541969f008d8065603579d9af Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sat, 26 Jan 2019 23:24:28 +0100 Subject: [PATCH 20/27] Final refactored `IFileSystem` and `ManagedFileSystem` --- .../IO/ManagedFileSystem.cs | 197 ++++-------------- MediaBrowser.Model/IO/IFileSystem.cs | 142 ++----------- 2 files changed, 63 insertions(+), 276 deletions(-) diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index 3e7774abfc..7c44878ec2 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -50,7 +50,7 @@ namespace Emby.Server.Implementations.IO _isEnvironmentCaseInsensitive = environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows; } - public string DefaultDirectory + public virtual string DefaultDirectory { get { @@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.IO { try { - if (DirectoryExists(value)) + if (Directory.Exists(value)) { return value; } @@ -75,7 +75,7 @@ namespace Emby.Server.Implementations.IO } } - public void AddShortcutHandler(IShortcutHandler handler) + public virtual void AddShortcutHandler(IShortcutHandler handler) { _shortcutHandlers.Add(handler); } @@ -94,13 +94,6 @@ namespace Emby.Server.Implementations.IO } } - public char DirectorySeparatorChar => Path.DirectorySeparatorChar; - - public string GetFullPath(string path) - { - return Path.GetFullPath(path); - } - /// /// Determines whether the specified filename is shortcut. /// @@ -142,7 +135,7 @@ namespace Emby.Server.Implementations.IO return null; } - public string MakeAbsolutePath(string folderPath, string filePath) + public virtual string MakeAbsolutePath(string folderPath, string filePath) { if (string.IsNullOrWhiteSpace(filePath)) return filePath; @@ -195,7 +188,7 @@ namespace Emby.Server.Implementations.IO /// or /// target /// - public void CreateShortcut(string shortcutPath, string target) + public virtual void CreateShortcut(string shortcutPath, string target) { if (string.IsNullOrEmpty(shortcutPath)) { @@ -227,7 +220,7 @@ namespace Emby.Server.Implementations.IO /// A object. /// If the specified path points to a directory, the returned object's /// property will be set to true and all other properties will reflect the properties of the directory. - public FileSystemMetadata GetFileSystemInfo(string path) + public virtual FileSystemMetadata GetFileSystemInfo(string path) { // Take a guess to try and avoid two file system hits, but we'll double-check by calling Exists if (Path.HasExtension(path)) @@ -262,7 +255,7 @@ namespace Emby.Server.Implementations.IO /// If the specified path points to a directory, the returned object's /// property and the property will both be set to false. /// For automatic handling of files and directories, use . - public FileSystemMetadata GetFileInfo(string path) + public virtual FileSystemMetadata GetFileInfo(string path) { var fileInfo = new FileInfo(path); @@ -277,7 +270,7 @@ namespace Emby.Server.Implementations.IO /// If the specified path points to a file, the returned object's /// property will be set to true and the property will be set to false. /// For automatic handling of files and directories, use . - public FileSystemMetadata GetDirectoryInfo(string path) + public virtual FileSystemMetadata GetDirectoryInfo(string path) { var fileInfo = new DirectoryInfo(path); @@ -339,24 +332,19 @@ namespace Emby.Server.Implementations.IO return result; } - /// - /// The space char - /// - private const char SpaceChar = ' '; - /// /// Takes a filename and removes invalid characters /// /// The filename. /// System.String. /// filename - public string GetValidFilename(string filename) + public virtual string GetValidFilename(string filename) { var builder = new StringBuilder(filename); foreach (var c in _invalidFileNameChars) { - builder = builder.Replace(c, SpaceChar); + builder = builder.Replace(c, ' '); } return builder.ToString(); @@ -386,17 +374,17 @@ namespace Emby.Server.Implementations.IO /// /// The path. /// DateTime. - public DateTime GetCreationTimeUtc(string path) + public virtual DateTime GetCreationTimeUtc(string path) { return GetCreationTimeUtc(GetFileSystemInfo(path)); } - public DateTime GetCreationTimeUtc(FileSystemMetadata info) + public virtual DateTime GetCreationTimeUtc(FileSystemMetadata info) { return info.CreationTimeUtc; } - public DateTime GetLastWriteTimeUtc(FileSystemMetadata info) + public virtual DateTime GetLastWriteTimeUtc(FileSystemMetadata info) { return info.LastWriteTimeUtc; } @@ -425,7 +413,7 @@ namespace Emby.Server.Implementations.IO /// /// The path. /// DateTime. - public DateTime GetLastWriteTimeUtc(string path) + public virtual DateTime GetLastWriteTimeUtc(string path) { return GetLastWriteTimeUtc(GetFileSystemInfo(path)); } @@ -439,7 +427,7 @@ namespace Emby.Server.Implementations.IO /// The share. /// if set to true [is asynchronous]. /// FileStream. - public Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false) + public virtual Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false) { if (_supportsAsyncFileStreams && isAsync) { @@ -449,7 +437,7 @@ namespace Emby.Server.Implementations.IO return GetFileStream(path, mode, access, share, FileOpenOptions.None); } - public Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, FileOpenOptions fileOpenOptions) + public virtual Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, FileOpenOptions fileOpenOptions) => new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 4096, GetFileOptions(fileOpenOptions)); private static FileOptions GetFileOptions(FileOpenOptions mode) @@ -511,7 +499,7 @@ namespace Emby.Server.Implementations.IO } } - public void SetHidden(string path, bool isHidden) + public virtual void SetHidden(string path, bool isHidden) { if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) { @@ -535,7 +523,7 @@ namespace Emby.Server.Implementations.IO } } - public void SetReadOnly(string path, bool isReadOnly) + public virtual void SetReadOnly(string path, bool isReadOnly) { if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) { @@ -559,7 +547,7 @@ namespace Emby.Server.Implementations.IO } } - public void SetAttributes(string path, bool isHidden, bool isReadOnly) + public virtual void SetAttributes(string path, bool isHidden, bool isReadOnly) { if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) { @@ -611,7 +599,7 @@ namespace Emby.Server.Implementations.IO /// /// The file1. /// The file2. - public void SwapFiles(string file1, string file2) + public virtual void SwapFiles(string file1, string file2) { if (string.IsNullOrEmpty(file1)) { @@ -630,18 +618,13 @@ namespace Emby.Server.Implementations.IO SetHidden(file2, false); Directory.CreateDirectory(_tempPath); - CopyFile(file1, temp1, true); + File.Copy(file1, temp1, true); - CopyFile(file2, file1, true); - CopyFile(temp1, file2, true); + File.Copy(file2, file1, true); + File.Copy(temp1, file2, true); } - private static char GetDirectorySeparatorChar(string path) - { - return Path.DirectorySeparatorChar; - } - - public bool ContainsSubPath(string parentPath, string path) + public virtual bool ContainsSubPath(string parentPath, string path) { if (string.IsNullOrEmpty(parentPath)) { @@ -653,19 +636,19 @@ namespace Emby.Server.Implementations.IO throw new ArgumentNullException(nameof(path)); } - var separatorChar = GetDirectorySeparatorChar(parentPath); + var separatorChar = Path.DirectorySeparatorChar; return path.IndexOf(parentPath.TrimEnd(separatorChar) + separatorChar, StringComparison.OrdinalIgnoreCase) != -1; } - public bool IsRootPath(string path) + public virtual bool IsRootPath(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } - var parent = GetDirectoryName(path); + var parent = Path.GetDirectoryName(path); if (!string.IsNullOrEmpty(parent)) { @@ -675,12 +658,7 @@ namespace Emby.Server.Implementations.IO return true; } - public string GetDirectoryName(string path) - { - return Path.GetDirectoryName(path); - } - - public string NormalizePath(string path) + public virtual string NormalizePath(string path) { if (string.IsNullOrEmpty(path)) { @@ -692,10 +670,10 @@ namespace Emby.Server.Implementations.IO return path; } - return path.TrimEnd(GetDirectorySeparatorChar(path)); + return path.TrimEnd(Path.DirectorySeparatorChar); } - public bool AreEqual(string path1, string path2) + public virtual bool AreEqual(string path1, string path2) { if (path1 == null && path2 == null) { @@ -710,7 +688,7 @@ namespace Emby.Server.Implementations.IO return string.Equals(NormalizePath(path1), NormalizePath(path2), StringComparison.OrdinalIgnoreCase); } - public string GetFileNameWithoutExtension(FileSystemMetadata info) + public virtual string GetFileNameWithoutExtension(FileSystemMetadata info) { if (info.IsDirectory) { @@ -720,12 +698,7 @@ namespace Emby.Server.Implementations.IO return Path.GetFileNameWithoutExtension(info.FullName); } - public string GetFileNameWithoutExtension(string path) - { - return Path.GetFileNameWithoutExtension(path); - } - - public bool IsPathFile(string path) + public virtual bool IsPathFile(string path) { // Cannot use Path.IsPathRooted because it returns false under mono when using windows-based paths, e.g. C:\\ @@ -740,23 +713,13 @@ namespace Emby.Server.Implementations.IO //return Path.IsPathRooted(path); } - public void DeleteFile(string path) + public virtual void DeleteFile(string path) { SetAttributes(path, false, false); File.Delete(path); } - - public void DeleteDirectory(string path, bool recursive) - { - Directory.Delete(path, recursive); - } - - public void CreateDirectory(string path) - { - Directory.CreateDirectory(path); - } - - public List GetDrives() + + public virtual List GetDrives() { // Only include drives in the ready state or this method could end up being very slow, waiting for drives to timeout return DriveInfo.GetDrives().Where(d => d.IsReady).Select(d => new FileSystemMetadata @@ -768,19 +731,19 @@ namespace Emby.Server.Implementations.IO }).ToList(); } - public IEnumerable GetDirectories(string path, bool recursive = false) + public virtual IEnumerable GetDirectories(string path, bool recursive = false) { var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; return ToMetadata(new DirectoryInfo(path).EnumerateDirectories("*", searchOption)); } - public IEnumerable GetFiles(string path, bool recursive = false) + public virtual IEnumerable GetFiles(string path, bool recursive = false) { return GetFiles(path, null, false, recursive); } - public IEnumerable GetFiles(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false) + public virtual IEnumerable GetFiles(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false) { var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; @@ -809,7 +772,7 @@ namespace Emby.Server.Implementations.IO return ToMetadata(files); } - public IEnumerable GetFileSystemEntries(string path, bool recursive = false) + public virtual IEnumerable GetFileSystemEntries(string path, bool recursive = false) { var directoryInfo = new DirectoryInfo(path); var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; @@ -827,89 +790,19 @@ namespace Emby.Server.Implementations.IO { return infos.Select(GetFileSystemMetadata); } - - public string[] ReadAllLines(string path) - { - return File.ReadAllLines(path); - } - - public void WriteAllLines(string path, IEnumerable lines) - { - File.WriteAllLines(path, lines); - } - - public Stream OpenRead(string path) - { - return File.OpenRead(path); - } - - public void CopyFile(string source, string target, bool overwrite) - { - File.Copy(source, target, overwrite); - } - - public void MoveFile(string source, string target) - { - File.Move(source, target); - } - - public void MoveDirectory(string source, string target) - { - Directory.Move(source, target); - } - - public bool DirectoryExists(string path) - { - return Directory.Exists(path); - } - - public bool FileExists(string path) - { - return File.Exists(path); - } - - public string ReadAllText(string path) - { - return File.ReadAllText(path); - } - - public byte[] ReadAllBytes(string path) - { - return File.ReadAllBytes(path); - } - - public void WriteAllText(string path, string text, Encoding encoding) - { - File.WriteAllText(path, text, encoding); - } - - public void WriteAllText(string path, string text) - { - File.WriteAllText(path, text); - } - - public void WriteAllBytes(string path, byte[] bytes) - { - File.WriteAllBytes(path, bytes); - } - - public string ReadAllText(string path, Encoding encoding) - { - return File.ReadAllText(path, encoding); - } - - public IEnumerable GetDirectoryPaths(string path, bool recursive = false) + + public virtual IEnumerable GetDirectoryPaths(string path, bool recursive = false) { var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; return Directory.EnumerateDirectories(path, "*", searchOption); } - public IEnumerable GetFilePaths(string path, bool recursive = false) + public virtual IEnumerable GetFilePaths(string path, bool recursive = false) { return GetFilePaths(path, null, false, recursive); } - public IEnumerable GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false) + public virtual IEnumerable GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false) { var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; @@ -938,7 +831,7 @@ namespace Emby.Server.Implementations.IO return files; } - public IEnumerable GetFileSystemEntryPaths(string path, bool recursive = false) + public virtual IEnumerable GetFileSystemEntryPaths(string path, bool recursive = false) { var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; return Directory.EnumerateFileSystemEntries(path, "*", searchOption); @@ -948,7 +841,7 @@ namespace Emby.Server.Implementations.IO { if (_environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX) { - RunProcess("chmod", "+x \"" + path + "\"", GetDirectoryName(path)); + RunProcess("chmod", "+x \"" + path + "\"", Path.GetDirectoryName(path)); } } diff --git a/MediaBrowser.Model/IO/IFileSystem.cs b/MediaBrowser.Model/IO/IFileSystem.cs index b8a315cccb..6c9b2bd883 100644 --- a/MediaBrowser.Model/IO/IFileSystem.cs +++ b/MediaBrowser.Model/IO/IFileSystem.cs @@ -36,32 +36,32 @@ namespace MediaBrowser.Model.IO string MakeAbsolutePath(string folderPath, string filePath); /// - /// Returns a object for the specified file or directory path. + /// Returns a object for the specified file or directory path. /// /// A path to a file or directory. - /// A object. - /// If the specified path points to a directory, the returned object's - /// property will be set to true and all other properties will reflect the properties of the directory. + /// A object. + /// If the specified path points to a directory, the returned object's + /// property will be set to true and all other properties will reflect the properties of the directory. FileSystemMetadata GetFileSystemInfo(string path); /// - /// Returns a object for the specified file path. + /// Returns a object for the specified file path. /// /// A path to a file. - /// A object. - /// If the specified path points to a directory, the returned object's - /// property and the property will both be set to false. - /// For automatic handling of files and directories, use . + /// A object. + /// If the specified path points to a directory, the returned object's + /// property and the property will both be set to false. + /// For automatic handling of files and directories, use . FileSystemMetadata GetFileInfo(string path); /// - /// Returns a object for the specified directory path. + /// Returns a object for the specified directory path. /// /// A path to a directory. - /// A object. - /// If the specified path points to a file, the returned object's - /// property will be set to true and the property will be set to false. - /// For automatic handling of files and directories, use . + /// A object. + /// If the specified path points to a file, the returned object's + /// property will be set to true and the property will be set to false. + /// For automatic handling of files and directories, use . FileSystemMetadata GetDirectoryInfo(string path); /// @@ -110,14 +110,8 @@ namespace MediaBrowser.Model.IO /// FileStream. Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false); - Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, FileOpenOptions fileOpenOptions); - - /// - /// Opens the read. - /// - /// The path. - /// Stream. - Stream OpenRead(string path); + Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, + FileOpenOptions fileOpenOptions); string DefaultDirectory { get; } @@ -152,8 +146,6 @@ namespace MediaBrowser.Model.IO /// System.String. string NormalizePath(string path); - string GetDirectoryName(string path); - /// /// Gets the file name without extension. /// @@ -161,13 +153,6 @@ namespace MediaBrowser.Model.IO /// System.String. string GetFileNameWithoutExtension(FileSystemMetadata info); - /// - /// Gets the file name without extension. - /// - /// The path. - /// System.String. - string GetFileNameWithoutExtension(string path); - /// /// Determines whether [is path file] [the specified path]. /// @@ -181,13 +166,6 @@ namespace MediaBrowser.Model.IO /// The path. void DeleteFile(string path); - /// - /// Deletes the directory. - /// - /// The path. - /// if set to true [recursive]. - void DeleteDirectory(string path, bool recursive); - /// /// Gets the directories. /// @@ -211,86 +189,6 @@ namespace MediaBrowser.Model.IO /// IEnumerable<FileSystemMetadata>. IEnumerable GetFileSystemEntries(string path, bool recursive = false); - /// - /// Creates the directory. - /// - /// The path. - void CreateDirectory(string path); - - /// - /// Copies the file. - /// - /// The source. - /// The target. - /// if set to true [overwrite]. - void CopyFile(string source, string target, bool overwrite); - - /// - /// Moves the file. - /// - /// The source. - /// The target. - void MoveFile(string source, string target); - - /// - /// Moves the directory. - /// - /// The source. - /// The target. - void MoveDirectory(string source, string target); - - /// - /// Directories the exists. - /// - /// The path. - /// true if XXXX, false otherwise. - bool DirectoryExists(string path); - - /// - /// Files the exists. - /// - /// The path. - /// true if XXXX, false otherwise. - bool FileExists(string path); - - /// - /// Reads all text. - /// - /// The path. - /// System.String. - string ReadAllText(string path); - - byte[] ReadAllBytes(string path); - - void WriteAllBytes(string path, byte[] bytes); - - /// - /// Writes all text. - /// - /// The path. - /// The text. - void WriteAllText(string path, string text); - - /// - /// Writes all text. - /// - /// The path. - /// The text. - /// The encoding. - void WriteAllText(string path, string text, Encoding encoding); - - /// - /// Reads all text. - /// - /// The path. - /// The encoding. - /// System.String. - string ReadAllText(string path, Encoding encoding); - - string[] ReadAllLines(string path); - - void WriteAllLines(string path, IEnumerable lines); - /// /// Gets the directory paths. /// @@ -306,6 +204,7 @@ namespace MediaBrowser.Model.IO /// if set to true [recursive]. /// IEnumerable<System.String>. IEnumerable GetFilePaths(string path, bool recursive = false); + IEnumerable GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive); /// @@ -319,15 +218,10 @@ namespace MediaBrowser.Model.IO void SetHidden(string path, bool isHidden); void SetReadOnly(string path, bool readOnly); void SetAttributes(string path, bool isHidden, bool readOnly); - - char DirectorySeparatorChar { get; } - - string GetFullPath(string path); - List GetDrives(); - void SetExecutable(string path); } + //TODO Investigate if can be replaced by the one from System.IO ? public enum FileOpenMode { From 1d1d7e8a3767cf0b13d6aa630bc587f4dc43b698 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 27 Jan 2019 15:48:26 +0100 Subject: [PATCH 21/27] Fixed inlining local-variable artifact. --- .../AppBase/BaseConfigurationManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index ec3ca8ead1..6da76ee7e4 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -209,9 +209,8 @@ namespace Emby.Server.Implementations.AppBase protected void EnsureWriteAccess(string path) { var file = Path.Combine(path, Guid.NewGuid().ToString()); - - string text = string.Empty; - File.WriteAllText(file, text); + + File.WriteAllText(file, string.Empty); FileSystem.DeleteFile(file); } From 838541b82530ce556cd5ab005ba59359f83c9509 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Mon, 28 Jan 2019 22:21:14 +0100 Subject: [PATCH 22/27] Removed loose whitespace and one .ToArray() call. --- Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs | 1 - Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 6da76ee7e4..90b43bc590 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -209,7 +209,6 @@ namespace Emby.Server.Implementations.AppBase protected void EnsureWriteAccess(string path) { var file = Path.Combine(path, Guid.NewGuid().ToString()); - File.WriteAllText(file, string.Empty); FileSystem.DeleteFile(file); } diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index c31bdd13d2..5373b4392b 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -143,7 +143,7 @@ namespace Emby.Server.Implementations.ScheduledTasks Directory.CreateDirectory(parentPath); - string text = string.Join("|", previouslyFailedImages.ToArray()); + string text = string.Join("|", previouslyFailedImages); File.WriteAllText(failHistoryPath, text); } From f06b9a14f3aed913d6154cdfdac74807f412ba30 Mon Sep 17 00:00:00 2001 From: Justin Suess Date: Mon, 28 Jan 2019 17:25:37 -0600 Subject: [PATCH 23/27] Added password as an API field to the Startup/User Service --- MediaBrowser.Api/StartupWizardService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 5f137d804c..f2002a8224 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -8,6 +8,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; +using MediaBrowser.Controller.Entities; namespace MediaBrowser.Api { @@ -102,7 +103,8 @@ namespace MediaBrowser.Api return new StartupUser { Name = user.Name, - ConnectUserName = user.ConnectUserName + ConnectUserName = user.ConnectUserName, + Password = user.Password }; } @@ -111,7 +113,9 @@ namespace MediaBrowser.Api var user = _userManager.Users.First(); user.Name = request.Name; + _userManager.UpdateUser(user); + await _userManager.ChangePassword(user, request.Password).ConfigureAwait(false); var result = new UpdateStartupUserResult(); @@ -130,6 +134,7 @@ namespace MediaBrowser.Api { public string Name { get; set; } public string ConnectUserName { get; set; } + public string Password { get; set; } } public class UpdateStartupUserResult From 6786dfcabddc73fc36f4ca65d18e05094ce4140f Mon Sep 17 00:00:00 2001 From: Justin Suess Date: Mon, 28 Jan 2019 17:37:20 -0600 Subject: [PATCH 24/27] Made password field non-mandatory upon setup --- MediaBrowser.Api/StartupWizardService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index f2002a8224..3d59b4c9a0 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -8,7 +8,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; -using MediaBrowser.Controller.Entities; namespace MediaBrowser.Api { @@ -115,7 +114,10 @@ namespace MediaBrowser.Api user.Name = request.Name; _userManager.UpdateUser(user); - await _userManager.ChangePassword(user, request.Password).ConfigureAwait(false); + + if (!string.IsNullOrEmpty(request.Password)) { + await _userManager.ChangePassword(user, request.Password).ConfigureAwait(false); + } var result = new UpdateStartupUserResult(); From 12e4c1c7aecb5cd1c8ab86716b3bff89a2690b98 Mon Sep 17 00:00:00 2001 From: Justin Suess Date: Mon, 28 Jan 2019 20:11:46 -0600 Subject: [PATCH 25/27] Added RazeLighter777 to the contributors file --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d918b7b95a..eca16ad382 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -16,6 +16,7 @@ - [wtayl0r](https://github.com/wtayl0r) - [TtheCreator](https://github.com/Tthecreator) - [LogicalPhallacy](https://github.com/LogicalPhallacy/) + - [RazeLighter777](https://github.com/RazeLighter777) # Emby Contributors From 91e99effc9b8dd1e34d4e53e732fe71f1423006c Mon Sep 17 00:00:00 2001 From: Vasily Date: Tue, 29 Jan 2019 14:45:07 +0100 Subject: [PATCH 26/27] Apply suggestions from code review for flipped conditions. Co-Authored-By: EraYaN --- .../Configuration/EncodingConfigurationFactory.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 2 +- MediaBrowser.Providers/TV/MissingEpisodeProvider.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs index c20d73dc73..bb806ee55c 100644 --- a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs +++ b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.MediaEncoding.Configuration && !string.Equals(oldEncodingConfig.TranscodingTempPath ?? string.Empty, newPath)) { // Validate - if (Directory.Exists(newPath)) + if (!Directory.Exists(newPath)) { throw new FileNotFoundException(string.Format("{0} does not exist.", newPath)); } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 7bcb1e38af..54344424de 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -214,7 +214,7 @@ namespace MediaBrowser.MediaEncoding.Encoder throw new ArgumentNullException(nameof(path)); } - if (!File.Exists(path) && Directory.Exists(path)) + if (!File.Exists(path) && !Directory.Exists(path)) { throw new ResourceNotFoundException(); } diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index fcdea33d01..4ac0123999 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.Providers.TV } // Check this in order to avoid logging an exception due to directory not existing - if (Directory.Exists(seriesDataPath)) + if (!Directory.Exists(seriesDataPath)) { return false; } From f8aff0c51d04420967da0e4adf1834515b1059f8 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Wed, 30 Jan 2019 01:02:17 +0100 Subject: [PATCH 27/27] Fix conditions where the ! was swallowed in #726 --- MediaBrowser.Api/EnvironmentService.cs | 4 ++-- MediaBrowser.Api/Library/LibraryStructureService.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index 907c44fe1d..bdd7a8f8f9 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -144,7 +144,7 @@ namespace MediaBrowser.Api } else { - if (Directory.Exists(request.Path)) + if (!Directory.Exists(request.Path)) { throw new FileNotFoundException("File not found", request.Path); } @@ -153,7 +153,7 @@ namespace MediaBrowser.Api else { - if (!File.Exists(request.Path) && Directory.Exists(request.Path)) + if (!File.Exists(request.Path) && !Directory.Exists(request.Path)) { throw new FileNotFoundException("Path not found", request.Path); } diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index c95a068051..d6bcf7878b 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -255,7 +255,7 @@ namespace MediaBrowser.Api.Library var currentPath = Path.Combine(rootFolderPath, request.Name); var newPath = Path.Combine(rootFolderPath, request.NewName); - if (Directory.Exists(currentPath)) + if (!Directory.Exists(currentPath)) { throw new FileNotFoundException("The media collection does not exist"); }