Browse Source

change zip extraction to resolve osx issue

Luke Pulverenti 10 years ago
parent
commit
c9bf564c45

+ 16 - 0
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);
+            }
+        }
+
         /// <summary>
         /// Extracts all from7z.
         /// </summary>

+ 8 - 0
MediaBrowser.Model/IO/IZipClient.cs

@@ -23,6 +23,14 @@ namespace MediaBrowser.Model.IO
         /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
         void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles);
 
+        /// <summary>
+        /// Extracts all from zip.
+        /// </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 ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles);
+
         /// <summary>
         /// Extracts all from7z.
         /// </summary>

+ 1 - 1
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);
                 }
             }