mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-22 03:37:25 +08:00
Replacing SharpZipLib by DtoNetZip
--HG-- branch : 1.x
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkProfile />
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -42,10 +46,8 @@
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\lib\sharpziplib\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="Ionic.Zip">
|
||||
<HintPath>..\..\..\..\lib\dotnetzip\Ionic.Zip.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Ionic.Zip;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.FileSystems.Media;
|
||||
@@ -293,21 +293,27 @@ namespace Orchard.Media.Services {
|
||||
Argument.ThrowIfNullOrEmpty(targetFolder, "targetFolder");
|
||||
Argument.ThrowIfNull(zipStream, "zipStream");
|
||||
|
||||
var fileInflater = new ZipInputStream(zipStream);
|
||||
ZipEntry entry;
|
||||
// We want to preserve whatever directory structure the zip file contained instead
|
||||
// of flattening it.
|
||||
// The API below doesn't necessarily return the entries in the zip file in any order.
|
||||
// That means the files in subdirectories can be returned as entries from the stream
|
||||
// before the directories that contain them, so we create directories as soon as first
|
||||
// file below their path is encountered.
|
||||
while ((entry = fileInflater.GetNextEntry()) != null) {
|
||||
if (!entry.IsDirectory && !string.IsNullOrEmpty(entry.Name)) {
|
||||
using (var fileInflater = ZipFile.Read(zipStream)) {
|
||||
// We want to preserve whatever directory structure the zip file contained instead
|
||||
// of flattening it.
|
||||
// The API below doesn't necessarily return the entries in the zip file in any order.
|
||||
// That means the files in subdirectories can be returned as entries from the stream
|
||||
// before the directories that contain them, so we create directories as soon as first
|
||||
// file below their path is encountered.
|
||||
foreach (ZipEntry entry in fileInflater) {
|
||||
if (entry == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip disallowed files
|
||||
if (FileAllowed(entry.Name, false)) {
|
||||
string fullFileName = _storageProvider.Combine(targetFolder, entry.Name);
|
||||
_storageProvider.TrySaveStream(fullFileName, fileInflater);
|
||||
if (!entry.IsDirectory && !string.IsNullOrEmpty(entry.FileName)) {
|
||||
|
||||
// skip disallowed files
|
||||
if (FileAllowed(entry.FileName, false)) {
|
||||
string fullFileName = _storageProvider.Combine(targetFolder, entry.FileName);
|
||||
using (var stream = entry.OpenReader()) {
|
||||
_storageProvider.TrySaveStream(fullFileName, stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user