From 89ff1f2af65283158e5ebe69bcc3d652b887ea34 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 28 Oct 2016 14:35:17 -0400 Subject: update components --- .../Archiving/ZipClient.cs | 189 --------------------- .../BaseApplicationHost.cs | 21 +-- .../IO/MemoryStreamProvider.cs | 45 ----- .../MediaBrowser.Common.Implementations.csproj | 17 +- .../packages.config | 5 +- 5 files changed, 8 insertions(+), 269 deletions(-) delete mode 100644 MediaBrowser.Common.Implementations/Archiving/ZipClient.cs delete mode 100644 MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs (limited to 'MediaBrowser.Common.Implementations') diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs deleted file mode 100644 index 24e816aef..000000000 --- a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs +++ /dev/null @@ -1,189 +0,0 @@ -using MediaBrowser.Model.IO; -using SharpCompress.Archive.Rar; -using SharpCompress.Archive.SevenZip; -using SharpCompress.Archive.Tar; -using SharpCompress.Common; -using SharpCompress.Reader; -using SharpCompress.Reader.Zip; -using System.IO; - -namespace MediaBrowser.Common.Implementations.Archiving -{ - /// - /// Class DotNetZipClient - /// - public class ZipClient : IZipClient - { - private readonly IFileSystem _fileSystem; - - public ZipClient(IFileSystem fileSystem) - { - _fileSystem = fileSystem; - } - - /// - /// Extracts all. - /// - /// The source file. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles) - { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) - { - ExtractAll(fileStream, targetPath, overwriteExistingFiles); - } - } - - /// - /// Extracts all. - /// - /// The source. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles) - { - using (var reader = ReaderFactory.Open(source)) - { - var options = ExtractOptions.ExtractFullPath; - - if (overwriteExistingFiles) - { - options = options | ExtractOptions.Overwrite; - } - - reader.WriteAllToDirectory(targetPath, options); - } - } - - public void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles) - { - using (var reader = ZipReader.Open(source)) - { - var options = ExtractOptions.ExtractFullPath; - - if (overwriteExistingFiles) - { - options = options | ExtractOptions.Overwrite; - } - - reader.WriteAllToDirectory(targetPath, options); - } - } - - /// - /// Extracts all from7z. - /// - /// The source file. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAllFrom7z(string sourceFile, string targetPath, bool overwriteExistingFiles) - { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) - { - ExtractAllFrom7z(fileStream, targetPath, overwriteExistingFiles); - } - } - - /// - /// Extracts all from7z. - /// - /// The source. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAllFrom7z(Stream source, string targetPath, bool overwriteExistingFiles) - { - using (var archive = SevenZipArchive.Open(source)) - { - using (var reader = archive.ExtractAllEntries()) - { - var options = ExtractOptions.ExtractFullPath; - - if (overwriteExistingFiles) - { - options = options | ExtractOptions.Overwrite; - } - - reader.WriteAllToDirectory(targetPath, options); - } - } - } - - - /// - /// Extracts all from tar. - /// - /// The source file. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAllFromTar(string sourceFile, string targetPath, bool overwriteExistingFiles) - { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) - { - ExtractAllFromTar(fileStream, targetPath, overwriteExistingFiles); - } - } - - /// - /// Extracts all from tar. - /// - /// The source. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles) - { - using (var archive = TarArchive.Open(source)) - { - using (var reader = archive.ExtractAllEntries()) - { - var options = ExtractOptions.ExtractFullPath; - - if (overwriteExistingFiles) - { - options = options | ExtractOptions.Overwrite; - } - - reader.WriteAllToDirectory(targetPath, options); - } - } - } - - /// - /// Extracts all from rar. - /// - /// The source file. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAllFromRar(string sourceFile, string targetPath, bool overwriteExistingFiles) - { - using (var fileStream = _fileSystem.OpenRead(sourceFile)) - { - ExtractAllFromRar(fileStream, targetPath, overwriteExistingFiles); - } - } - - /// - /// Extracts all from rar. - /// - /// The source. - /// The target path. - /// if set to true [overwrite existing files]. - public void ExtractAllFromRar(Stream source, string targetPath, bool overwriteExistingFiles) - { - using (var archive = RarArchive.Open(source)) - { - using (var reader = archive.ExtractAllEntries()) - { - var options = ExtractOptions.ExtractFullPath; - - if (overwriteExistingFiles) - { - options = options | ExtractOptions.Overwrite; - } - - reader.WriteAllToDirectory(targetPath, options); - } - } - } - } -} diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 0639a6bb7..3b1499419 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; -using MediaBrowser.Common.Implementations.Archiving; using MediaBrowser.Common.Implementations.Devices; using MediaBrowser.Common.Implementations.IO; using MediaBrowser.Common.Implementations.ScheduledTasks; @@ -158,12 +157,6 @@ namespace MediaBrowser.Common.Implementations protected IFileSystem FileSystemManager { get; private set; } - /// - /// Gets or sets the zip client. - /// - /// The zip client. - protected IZipClient ZipClient { get; private set; } - protected IIsoManager IsoManager { get; private set; } /// @@ -243,14 +236,7 @@ namespace MediaBrowser.Common.Implementations JsonSerializer = CreateJsonSerializer(); - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - { - MemoryStreamProvider = new RecyclableMemoryStreamProvider(); - } - else - { - MemoryStreamProvider = new MemoryStreamProvider(); - } + MemoryStreamProvider = CreateMemoryStreamProvider(); OnLoggerLoaded(true); LogManager.LoggerLoaded += (s, e) => OnLoggerLoaded(false); @@ -283,6 +269,8 @@ namespace MediaBrowser.Common.Implementations progress.Report(100); } + protected abstract IMemoryStreamProvider CreateMemoryStreamProvider(); + protected virtual void OnLoggerLoaded(bool isFirstLoad) { Logger.Info("Application version: {0}", ApplicationVersion); @@ -531,9 +519,6 @@ namespace MediaBrowser.Common.Implementations InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager); RegisterSingleInstance(InstallationManager); - ZipClient = new ZipClient(FileSystemManager); - RegisterSingleInstance(ZipClient); - IsoManager = new IsoManager(); RegisterSingleInstance(IsoManager); diff --git a/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs b/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs deleted file mode 100644 index cc3bf0788..000000000 --- a/MediaBrowser.Common.Implementations/IO/MemoryStreamProvider.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.IO; -using MediaBrowser.Common.IO; -using MediaBrowser.Model.IO; -using Microsoft.IO; - -namespace MediaBrowser.Common.Implementations.IO -{ - public class RecyclableMemoryStreamProvider : IMemoryStreamProvider - { - readonly RecyclableMemoryStreamManager _manager = new RecyclableMemoryStreamManager(); - - public MemoryStream CreateNew() - { - return _manager.GetStream(); - } - - public MemoryStream CreateNew(int capacity) - { - return _manager.GetStream("RecyclableMemoryStream", capacity); - } - - public MemoryStream CreateNew(byte[] buffer) - { - return _manager.GetStream("RecyclableMemoryStream", buffer, 0, buffer.Length); - } - } - - public class MemoryStreamProvider : IMemoryStreamProvider - { - public MemoryStream CreateNew() - { - return new MemoryStream(); - } - - public MemoryStream CreateNew(int capacity) - { - return new MemoryStream(capacity); - } - - public MemoryStream CreateNew(byte[] buffer) - { - return new MemoryStream(buffer); - } - } -} diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index f68905ab9..ce776b245 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -45,30 +45,21 @@ Always - - ..\packages\Microsoft.IO.RecyclableMemoryStream.1.1.0.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll - True - - ..\packages\NLog.4.3.8\lib\net45\NLog.dll + ..\packages\NLog.4.3.10\lib\net45\NLog.dll True ..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll - - False - ..\ThirdParty\SharpCompress\SharpCompress.dll - - - ..\packages\SimpleInjector.3.2.2\lib\net45\SimpleInjector.dll + + ..\packages\SimpleInjector.3.2.4\lib\net45\SimpleInjector.dll True - @@ -79,7 +70,6 @@ Properties\SharedVersion.cs - @@ -91,7 +81,6 @@ - diff --git a/MediaBrowser.Common.Implementations/packages.config b/MediaBrowser.Common.Implementations/packages.config index 1dceb69bb..4eacd0d72 100644 --- a/MediaBrowser.Common.Implementations/packages.config +++ b/MediaBrowser.Common.Implementations/packages.config @@ -1,7 +1,6 @@  - - + - + \ No newline at end of file -- cgit v1.2.3