change zip extraction to resolve osx issue

This commit is contained in:
Luke Pulverenti 2014-12-28 21:50:02 -05:00
parent a7f2bc5fda
commit c9bf564c45
3 changed files with 25 additions and 1 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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);
}
}