isolated DotNetZip dependancy

This commit is contained in:
LukePulverenti 2013-02-21 00:00:56 -05:00
parent a0ced20d5b
commit acf5b0b6ed
12 changed files with 134 additions and 28 deletions

View File

@ -26,8 +26,14 @@ namespace MediaBrowser.Common.Kernel
/// Initializes a new instance of the <see cref="BaseManager" /> class. /// Initializes a new instance of the <see cref="BaseManager" /> class.
/// </summary> /// </summary>
/// <param name="kernel">The kernel.</param> /// <param name="kernel">The kernel.</param>
/// <exception cref="System.ArgumentNullException">kernel</exception>
protected BaseManager(TKernelType kernel) protected BaseManager(TKernelType kernel)
{ {
if (kernel == null)
{
throw new ArgumentNullException("kernel");
}
Kernel = kernel; Kernel = kernel;
Logger = LogManager.GetLogger(GetType().Name); Logger = LogManager.GetLogger(GetType().Name);

View File

@ -15,6 +15,7 @@ using MediaBrowser.Controller.ScheduledTasks;
using MediaBrowser.Controller.Updates; using MediaBrowser.Controller.Updates;
using MediaBrowser.Controller.Weather; using MediaBrowser.Controller.Weather;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -297,13 +298,20 @@ namespace MediaBrowser.Controller
get { return 7359; } get { return 7359; }
} }
/// <summary>
/// Gets or sets the zip client.
/// </summary>
/// <value>The zip client.</value>
private IZipClient ZipClient { get; set; }
/// <summary> /// <summary>
/// Creates a kernel based on a Data path, which is akin to our current programdata path /// Creates a kernel based on a Data path, which is akin to our current programdata path
/// </summary> /// </summary>
public Kernel(IIsoManager isoManager) public Kernel(IIsoManager isoManager, IZipClient zipClient)
: base(isoManager) : base(isoManager)
{ {
Instance = this; Instance = this;
ZipClient = zipClient;
} }
/// <summary> /// <summary>
@ -319,10 +327,10 @@ namespace MediaBrowser.Controller
RootFolder = null; RootFolder = null;
ReloadResourcePools(); ReloadResourcePools();
InstallationManager = new InstallationManager(this); InstallationManager = new InstallationManager(this, ZipClient);
LibraryManager = new LibraryManager(this); LibraryManager = new LibraryManager(this);
UserManager = new UserManager(this); UserManager = new UserManager(this);
FFMpegManager = new FFMpegManager(this); FFMpegManager = new FFMpegManager(this, ZipClient);
ImageManager = new ImageManager(this); ImageManager = new ImageManager(this);
ProviderManager = new ProviderManager(this); ProviderManager = new ProviderManager(this);
UserDataManager = new UserDataManager(this); UserDataManager = new UserDataManager(this);

View File

@ -53,9 +53,6 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Ionic.Zip">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="Mediabrowser.PluginSecurity"> <Reference Include="Mediabrowser.PluginSecurity">
<HintPath>Plugins\Mediabrowser.PluginSecurity.dll</HintPath> <HintPath>Plugins\Mediabrowser.PluginSecurity.dll</HintPath>
</Reference> </Reference>

View File

@ -1,5 +1,4 @@
using Ionic.Zip; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO; using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Serialization; using MediaBrowser.Common.Serialization;
@ -7,6 +6,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -59,13 +59,28 @@ namespace MediaBrowser.Controller.MediaInfo
/// <value>The subtitle cache.</value> /// <value>The subtitle cache.</value>
internal FileSystemRepository SubtitleCache { get; set; } internal FileSystemRepository SubtitleCache { get; set; }
/// <summary>
/// Gets or sets the zip client.
/// </summary>
/// <value>The zip client.</value>
private IZipClient ZipClient { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FFMpegManager" /> class. /// Initializes a new instance of the <see cref="FFMpegManager" /> class.
/// </summary> /// </summary>
/// <param name="kernel">The kernel.</param> /// <param name="kernel">The kernel.</param>
public FFMpegManager(Kernel kernel) /// <param name="zipClient">The zip client.</param>
/// <exception cref="System.ArgumentNullException">zipClient</exception>
public FFMpegManager(Kernel kernel, IZipClient zipClient)
: base(kernel) : base(kernel)
{ {
if (zipClient == null)
{
throw new ArgumentNullException("zipClient");
}
ZipClient = zipClient;
// Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
@ -352,10 +367,7 @@ namespace MediaBrowser.Controller.MediaInfo
{ {
using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath)) using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath))
{ {
using (var zipFile = ZipFile.Read(resourceStream)) ZipClient.ExtractAll(resourceStream, targetPath, false);
{
zipFile.ExtractAll(targetPath, ExtractExistingFileAction.DoNotOverwrite);
}
} }
} }

View File

@ -1,11 +1,11 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using Ionic.Zip;
using MediaBrowser.Common.Events; using MediaBrowser.Common.Events;
using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Progress; using MediaBrowser.Common.Progress;
using MediaBrowser.Common.Serialization; using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Updates; using MediaBrowser.Model.Updates;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -91,14 +91,27 @@ namespace MediaBrowser.Controller.Updates
} }
#endregion #endregion
/// <summary>
/// Gets or sets the zip client.
/// </summary>
/// <value>The zip client.</value>
private IZipClient ZipClient { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="InstallationManager" /> class. /// Initializes a new instance of the <see cref="InstallationManager" /> class.
/// </summary> /// </summary>
/// <param name="kernel">The kernel.</param> /// <param name="kernel">The kernel.</param>
public InstallationManager(Kernel kernel) /// <param name="zipClient">The zip client.</param>
/// <exception cref="System.ArgumentNullException">zipClient</exception>
public InstallationManager(Kernel kernel, IZipClient zipClient)
: base(kernel) : base(kernel)
{ {
if (zipClient == null)
{
throw new ArgumentNullException("zipClient");
}
ZipClient = zipClient;
} }
/// <summary> /// <summary>
@ -391,11 +404,7 @@ namespace MediaBrowser.Controller.Updates
{ {
try try
{ {
// Extract to target in full - overwriting ZipClient.ExtractAll(tempFile, target, true);
using (var zipFile = ZipFile.Read(tempFile))
{
zipFile.ExtractAll(target, ExtractExistingFileAction.OverwriteSilently);
}
} }
catch (IOException e) catch (IOException e)
{ {

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
<package id="morelinq" version="1.0.15631-beta" targetFramework="net45" /> <package id="morelinq" version="1.0.15631-beta" targetFramework="net45" />
<package id="protobuf-net" version="2.0.0.621" targetFramework="net45" /> <package id="protobuf-net" version="2.0.0.621" targetFramework="net45" />
</packages> </packages>

View File

@ -0,0 +1,26 @@
using System.IO;
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Interface IZipClient
/// </summary>
public interface IZipClient
{
/// <summary>
/// Extracts all.
/// </summary>
/// <param name="sourceFile">The source file.</param>
/// <param name="targetPath">The target path.</param>
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles);
/// <summary>
/// Extracts all.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="targetPath">The target path.</param>
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles);
}
}

View File

@ -64,6 +64,7 @@
<Compile Include="Entities\IHasMediaStreams.cs" /> <Compile Include="Entities\IHasMediaStreams.cs" />
<Compile Include="Entities\VideoFormat.cs" /> <Compile Include="Entities\VideoFormat.cs" />
<Compile Include="Extensions\ModelExtensions.cs" /> <Compile Include="Extensions\ModelExtensions.cs" />
<Compile Include="IO\IZipClient.cs" />
<Compile Include="Logging\ILogger.cs" /> <Compile Include="Logging\ILogger.cs" />
<Compile Include="Logging\LogSeverity.cs" /> <Compile Include="Logging\LogSeverity.cs" />
<Compile Include="Net\HttpException.cs" /> <Compile Include="Net\HttpException.cs" />

View File

@ -1,13 +1,12 @@
using MediaBrowser.Common.IO; using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.UI; using MediaBrowser.Common.UI;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.IsoMounter; using MediaBrowser.IsoMounter;
using MediaBrowser.Server.Uninstall; using MediaBrowser.Server.Uninstall;
using MediaBrowser.ServerApplication.Implementations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
@ -170,7 +169,7 @@ namespace MediaBrowser.ServerApplication
/// <returns>IKernel.</returns> /// <returns>IKernel.</returns>
protected override IKernel InstantiateKernel() protected override IKernel InstantiateKernel()
{ {
return new Kernel(new PismoIsoManager()); return new Kernel(new PismoIsoManager(), new DotNetZipClient());
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,43 @@
using Ionic.Zip;
using MediaBrowser.Model.IO;
using System.IO;
namespace MediaBrowser.ServerApplication.Implementations
{
/// <summary>
/// Class DotNetZipClient
/// </summary>
public class DotNetZipClient : IZipClient
{
/// <summary>
/// Extracts all.
/// </summary>
/// <param name="sourceFile">The source file.</param>
/// <param name="targetPath">The target path.</param>
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
public void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles)
{
using (var fileStream = File.OpenRead(sourceFile))
{
using (var zipFile = ZipFile.Read(fileStream))
{
zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
}
}
}
/// <summary>
/// Extracts all.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="targetPath">The target path.</param>
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles)
{
using (var zipFile = ZipFile.Read(source))
{
zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
}
}
}
}

View File

@ -115,6 +115,10 @@
<Reference Include="Hardcodet.Wpf.TaskbarNotification"> <Reference Include="Hardcodet.Wpf.TaskbarNotification">
<HintPath>..\packages\Hardcodet.Wpf.TaskbarNotification.1.0.4.0\lib\net40\Hardcodet.Wpf.TaskbarNotification.dll</HintPath> <HintPath>..\packages\Hardcodet.Wpf.TaskbarNotification.1.0.4.0\lib\net40\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
</Reference> </Reference>
<Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
<Reference Include="Platinum.Managed, Version=1.0.4794.22684, Culture=neutral, processorArchitecture=x86"> <Reference Include="Platinum.Managed, Version=1.0.4794.22684, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\UPnP\Libs\Platinum.Managed.dll</HintPath> <HintPath>..\ThirdParty\UPnP\Libs\Platinum.Managed.dll</HintPath>
@ -175,6 +179,7 @@
<Compile Include="Controls\MultiItemUpdateNotification.xaml.cs"> <Compile Include="Controls\MultiItemUpdateNotification.xaml.cs">
<DependentUpon>MultiItemUpdateNotification.xaml</DependentUpon> <DependentUpon>MultiItemUpdateNotification.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Implementations\DotNetZipClient.cs" />
<Compile Include="LibraryExplorer.xaml.cs"> <Compile Include="LibraryExplorer.xaml.cs">
<DependentUpon>LibraryExplorer.xaml</DependentUpon> <DependentUpon>LibraryExplorer.xaml</DependentUpon>
</Compile> </Compile>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
<package id="Hardcodet.Wpf.TaskbarNotification" version="1.0.4.0" targetFramework="net45" /> <package id="Hardcodet.Wpf.TaskbarNotification" version="1.0.4.0" targetFramework="net45" />
<package id="System.Data.SQLite" version="1.0.84.0" targetFramework="net45" /> <package id="System.Data.SQLite" version="1.0.84.0" targetFramework="net45" />
</packages> </packages>