From c9bf564c4523798fc6b2250fba41daed4f89939d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 28 Dec 2014 21:50:02 -0500 Subject: [PATCH] change zip extraction to resolve osx issue --- .../Archiving/ZipClient.cs | 16 ++++++++++++++++ MediaBrowser.Model/IO/IZipClient.cs | 8 ++++++++ MediaBrowser.Providers/TV/TvdbSeriesProvider.cs | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs index 23d40cf67..3d759ca54 100644 --- a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs +++ b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs @@ -4,6 +4,7 @@ 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 @@ -48,6 +49,21 @@ namespace MediaBrowser.Common.Implementations.Archiving } } + 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. /// diff --git a/MediaBrowser.Model/IO/IZipClient.cs b/MediaBrowser.Model/IO/IZipClient.cs index ba0725da5..ac57d58a6 100644 --- a/MediaBrowser.Model/IO/IZipClient.cs +++ b/MediaBrowser.Model/IO/IZipClient.cs @@ -23,6 +23,14 @@ namespace MediaBrowser.Model.IO /// if set to true [overwrite existing files]. void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles); + /// + /// Extracts all from zip. + /// + /// The source. + /// The target path. + /// if set to true [overwrite existing files]. + void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles); + /// /// Extracts all from7z. /// diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index 69f1123d0..20dc6c485 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -210,7 +210,7 @@ namespace MediaBrowser.Providers.TV await zipStream.CopyToAsync(ms).ConfigureAwait(false); ms.Position = 0; - _zipClient.ExtractAll(ms, seriesDataPath, true); + _zipClient.ExtractAllFromZip(ms, seriesDataPath, true); } }