diff --git a/MediaBrowser.Common/Kernel/BaseManager.cs b/MediaBrowser.Common/Kernel/BaseManager.cs
index a9aff4d1c..565e4295e 100644
--- a/MediaBrowser.Common/Kernel/BaseManager.cs
+++ b/MediaBrowser.Common/Kernel/BaseManager.cs
@@ -26,8 +26,14 @@ namespace MediaBrowser.Common.Kernel
/// Initializes a new instance of the class.
///
/// The kernel.
+ /// kernel
protected BaseManager(TKernelType kernel)
{
+ if (kernel == null)
+ {
+ throw new ArgumentNullException("kernel");
+ }
+
Kernel = kernel;
Logger = LogManager.GetLogger(GetType().Name);
diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs
index c4d8f3e6c..22c241fd4 100644
--- a/MediaBrowser.Controller/Kernel.cs
+++ b/MediaBrowser.Controller/Kernel.cs
@@ -15,6 +15,7 @@ using MediaBrowser.Controller.ScheduledTasks;
using MediaBrowser.Controller.Updates;
using MediaBrowser.Controller.Weather;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.System;
using System;
using System.Collections.Generic;
@@ -297,13 +298,20 @@ namespace MediaBrowser.Controller
get { return 7359; }
}
+ ///
+ /// Gets or sets the zip client.
+ ///
+ /// The zip client.
+ private IZipClient ZipClient { get; set; }
+
///
/// Creates a kernel based on a Data path, which is akin to our current programdata path
///
- public Kernel(IIsoManager isoManager)
+ public Kernel(IIsoManager isoManager, IZipClient zipClient)
: base(isoManager)
{
Instance = this;
+ ZipClient = zipClient;
}
///
@@ -319,10 +327,10 @@ namespace MediaBrowser.Controller
RootFolder = null;
ReloadResourcePools();
- InstallationManager = new InstallationManager(this);
+ InstallationManager = new InstallationManager(this, ZipClient);
LibraryManager = new LibraryManager(this);
UserManager = new UserManager(this);
- FFMpegManager = new FFMpegManager(this);
+ FFMpegManager = new FFMpegManager(this, ZipClient);
ImageManager = new ImageManager(this);
ProviderManager = new ProviderManager(this);
UserDataManager = new UserDataManager(this);
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index e15e053be..f911f190d 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -53,9 +53,6 @@
MinimumRecommendedRules.ruleset
-
- ..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll
-
Plugins\Mediabrowser.PluginSecurity.dll
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
index ee7c87f90..ad0b3a63f 100644
--- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
+++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
@@ -1,5 +1,4 @@
-using Ionic.Zip;
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Serialization;
@@ -7,6 +6,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.IO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -58,14 +58,29 @@ namespace MediaBrowser.Controller.MediaInfo
///
/// The subtitle cache.
internal FileSystemRepository SubtitleCache { get; set; }
-
+
+ ///
+ /// Gets or sets the zip client.
+ ///
+ /// The zip client.
+ private IZipClient ZipClient { get; set; }
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public FFMpegManager(Kernel kernel)
+ /// The zip client.
+ /// zipClient
+ public FFMpegManager(Kernel kernel, IZipClient zipClient)
: 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
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 zipFile = ZipFile.Read(resourceStream))
- {
- zipFile.ExtractAll(targetPath, ExtractExistingFileAction.DoNotOverwrite);
- }
+ ZipClient.ExtractAll(resourceStream, targetPath, false);
}
}
@@ -383,7 +395,7 @@ namespace MediaBrowser.Controller.MediaInfo
{
return "-probesize 1G -analyzeduration 200M";
}
-
+
return string.Empty;
}
@@ -818,7 +830,7 @@ namespace MediaBrowser.Controller.MediaInfo
{
throw new ArgumentException("The given MediaStream is not an external subtitle stream");
}
-
+
var process = new Process
{
StartInfo = new ProcessStartInfo
diff --git a/MediaBrowser.Controller/Updates/InstallationManager.cs b/MediaBrowser.Controller/Updates/InstallationManager.cs
index 63afa2ce8..8b4a613b9 100644
--- a/MediaBrowser.Controller/Updates/InstallationManager.cs
+++ b/MediaBrowser.Controller/Updates/InstallationManager.cs
@@ -1,11 +1,11 @@
using System.Security.Cryptography;
-using Ionic.Zip;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Progress;
using MediaBrowser.Common.Serialization;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.Updates;
using System;
using System.Collections.Concurrent;
@@ -91,14 +91,27 @@ namespace MediaBrowser.Controller.Updates
}
#endregion
+ ///
+ /// Gets or sets the zip client.
+ ///
+ /// The zip client.
+ private IZipClient ZipClient { get; set; }
+
///
/// Initializes a new instance of the class.
///
/// The kernel.
- public InstallationManager(Kernel kernel)
+ /// The zip client.
+ /// zipClient
+ public InstallationManager(Kernel kernel, IZipClient zipClient)
: base(kernel)
{
+ if (zipClient == null)
+ {
+ throw new ArgumentNullException("zipClient");
+ }
+ ZipClient = zipClient;
}
///
@@ -391,11 +404,7 @@ namespace MediaBrowser.Controller.Updates
{
try
{
- // Extract to target in full - overwriting
- using (var zipFile = ZipFile.Read(tempFile))
- {
- zipFile.ExtractAll(target, ExtractExistingFileAction.OverwriteSilently);
- }
+ ZipClient.ExtractAll(tempFile, target, true);
}
catch (IOException e)
{
diff --git a/MediaBrowser.Controller/packages.config b/MediaBrowser.Controller/packages.config
index 1ba8ce452..e3e4367b7 100644
--- a/MediaBrowser.Controller/packages.config
+++ b/MediaBrowser.Controller/packages.config
@@ -1,6 +1,5 @@
-
\ No newline at end of file
diff --git a/MediaBrowser.Model/IO/IZipClient.cs b/MediaBrowser.Model/IO/IZipClient.cs
new file mode 100644
index 000000000..c9e7e0db6
--- /dev/null
+++ b/MediaBrowser.Model/IO/IZipClient.cs
@@ -0,0 +1,26 @@
+using System.IO;
+
+namespace MediaBrowser.Model.IO
+{
+ ///
+ /// Interface IZipClient
+ ///
+ public interface IZipClient
+ {
+ ///
+ /// Extracts all.
+ ///
+ /// The source file.
+ /// The target path.
+ /// if set to true [overwrite existing files].
+ void ExtractAll(string sourceFile, string targetPath, bool overwriteExistingFiles);
+
+ ///
+ /// Extracts all.
+ ///
+ /// The source.
+ /// The target path.
+ /// if set to true [overwrite existing files].
+ void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles);
+ }
+}
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 9a7f65caa..dd11a131a 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -64,6 +64,7 @@
+
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs
index 487b60485..e50370444 100644
--- a/MediaBrowser.ServerApplication/App.xaml.cs
+++ b/MediaBrowser.ServerApplication/App.xaml.cs
@@ -1,13 +1,12 @@
-using MediaBrowser.Common.IO;
-using MediaBrowser.Common.Kernel;
+using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.UI;
using MediaBrowser.Controller;
using MediaBrowser.IsoMounter;
using MediaBrowser.Server.Uninstall;
+using MediaBrowser.ServerApplication.Implementations;
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Windows;
@@ -170,7 +169,7 @@ namespace MediaBrowser.ServerApplication
/// IKernel.
protected override IKernel InstantiateKernel()
{
- return new Kernel(new PismoIsoManager());
+ return new Kernel(new PismoIsoManager(), new DotNetZipClient());
}
///
diff --git a/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs b/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs
new file mode 100644
index 000000000..3b174a9b2
--- /dev/null
+++ b/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs
@@ -0,0 +1,43 @@
+using Ionic.Zip;
+using MediaBrowser.Model.IO;
+using System.IO;
+
+namespace MediaBrowser.ServerApplication.Implementations
+{
+ ///
+ /// Class DotNetZipClient
+ ///
+ public class DotNetZipClient : IZipClient
+ {
+ ///
+ /// 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 = File.OpenRead(sourceFile))
+ {
+ using (var zipFile = ZipFile.Read(fileStream))
+ {
+ zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
+ }
+ }
+ }
+
+ ///
+ /// 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 zipFile = ZipFile.Read(source))
+ {
+ zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 74e437564..86ad7dcaf 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -115,6 +115,10 @@
..\packages\Hardcodet.Wpf.TaskbarNotification.1.0.4.0\lib\net40\Hardcodet.Wpf.TaskbarNotification.dll
+
+ False
+ ..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll
+
False
..\ThirdParty\UPnP\Libs\Platinum.Managed.dll
@@ -175,6 +179,7 @@
MultiItemUpdateNotification.xaml
+
LibraryExplorer.xaml
diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config
index 868a15c6d..c1e5c8098 100644
--- a/MediaBrowser.ServerApplication/packages.config
+++ b/MediaBrowser.ServerApplication/packages.config
@@ -1,5 +1,6 @@
+
\ No newline at end of file