Browse Source

minor changes

pull/1379/head
Yunus Emre Kalkan 7 years ago
parent
commit
05051241d3
  1. 44
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
  2. 26
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateProjectResultZipStep.cs
  3. 26
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/FileEntryListReadStep.cs

44
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs

@ -62,31 +62,33 @@ namespace Volo.Abp.Cli.Commands
using (var templateFileStream = new MemoryStream(result.ZipContent)) using (var templateFileStream = new MemoryStream(result.ZipContent))
{ {
var zipInputStream = new ZipInputStream(templateFileStream); using (var zipInputStream = new ZipInputStream(templateFileStream))
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
{ {
var fullZipToPath = Path.Combine(outputFolder, zipEntry.Name); var zipEntry = zipInputStream.GetNextEntry();
var directoryName = Path.GetDirectoryName(fullZipToPath); while (zipEntry != null)
if (!string.IsNullOrEmpty(directoryName))
{
Directory.CreateDirectory(directoryName);
}
var fileName = Path.GetFileName(fullZipToPath);
if (fileName.Length == 0)
{ {
var fullZipToPath = Path.Combine(outputFolder, zipEntry.Name);
var directoryName = Path.GetDirectoryName(fullZipToPath);
if (!string.IsNullOrEmpty(directoryName))
{
Directory.CreateDirectory(directoryName);
}
var fileName = Path.GetFileName(fullZipToPath);
if (fileName.Length == 0)
{
zipEntry = zipInputStream.GetNextEntry();
continue;
}
var buffer = new byte[4096]; // 4K is optimum
using (var streamWriter = File.Create(fullZipToPath))
{
StreamUtils.Copy(zipInputStream, streamWriter, buffer);
}
zipEntry = zipInputStream.GetNextEntry(); zipEntry = zipInputStream.GetNextEntry();
continue;
}
var buffer = new byte[4096]; // 4K is optimum
using (var streamWriter = File.Create(fullZipToPath))
{
StreamUtils.Copy(zipInputStream, streamWriter, buffer);
} }
zipEntry = zipInputStream.GetNextEntry();
} }
} }

26
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateProjectResultZipStep.cs

@ -15,22 +15,22 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
{ {
using (var memoryStream = new MemoryStream()) using (var memoryStream = new MemoryStream())
{ {
var zipOutputStream = new ZipOutputStream(memoryStream); using (var zipOutputStream = new ZipOutputStream(memoryStream))
zipOutputStream.SetLevel(3); //0-9, 9 being the highest level of compression
foreach (var entry in entries)
{ {
zipOutputStream.PutNextEntry(new ZipEntry(entry.Name) zipOutputStream.SetLevel(3); //0-9, 9 being the highest level of compression
{
Size = entry.Bytes.Length
});
zipOutputStream.Write(entry.Bytes, 0, entry.Bytes.Length);
}
zipOutputStream.CloseEntry(); foreach (var entry in entries)
{
zipOutputStream.PutNextEntry(new ZipEntry(entry.Name)
{
Size = entry.Bytes.Length
});
zipOutputStream.Write(entry.Bytes, 0, entry.Bytes.Length);
}
zipOutputStream.IsStreamOwner = false; zipOutputStream.CloseEntry();
zipOutputStream.Close(); zipOutputStream.IsStreamOwner = false;
}
memoryStream.Position = 0; memoryStream.Position = 0;
return memoryStream.ToArray(); return memoryStream.ToArray();

26
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/FileEntryListReadStep.cs

@ -16,23 +16,25 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
private static FileEntryList GetEntriesFromZipFile(byte[] fileBytes) private static FileEntryList GetEntriesFromZipFile(byte[] fileBytes)
{ {
var fileEntries = new List<FileEntry>();
using (var memoryStream = new MemoryStream(fileBytes)) using (var memoryStream = new MemoryStream(fileBytes))
{ {
var fileEntries = new List<FileEntry>(); using (var zipInputStream = new ZipInputStream(memoryStream))
var zipInputStream = new ZipInputStream(memoryStream);
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
{ {
var buffer = new byte[4096]; // 4K is optimum var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
using (var fileEntryMemoryStream = new MemoryStream())
{ {
StreamUtils.Copy(zipInputStream, fileEntryMemoryStream, buffer); var buffer = new byte[4096]; // 4K is optimum
fileEntries.Add(new FileEntry(zipEntry.Name.EnsureStartsWith('/'), fileEntryMemoryStream.ToArray(), zipEntry.IsDirectory));
} using (var fileEntryMemoryStream = new MemoryStream())
{
StreamUtils.Copy(zipInputStream, fileEntryMemoryStream, buffer);
fileEntries.Add(new FileEntry(zipEntry.Name.EnsureStartsWith('/'), fileEntryMemoryStream.ToArray(), zipEntry.IsDirectory));
}
zipEntry = zipInputStream.GetNextEntry(); zipEntry = zipInputStream.GetNextEntry();
}
} }
return new FileEntryList(fileEntries); return new FileEntryList(fileEntries);

Loading…
Cancel
Save