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))
{
var zipInputStream = new ZipInputStream(templateFileStream);
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
using (var zipInputStream = new ZipInputStream(templateFileStream))
{
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)
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
{
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();
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())
{
var zipOutputStream = new ZipOutputStream(memoryStream);
zipOutputStream.SetLevel(3); //0-9, 9 being the highest level of compression
foreach (var entry in entries)
using (var zipOutputStream = new ZipOutputStream(memoryStream))
{
zipOutputStream.PutNextEntry(new ZipEntry(entry.Name)
{
Size = entry.Bytes.Length
});
zipOutputStream.Write(entry.Bytes, 0, entry.Bytes.Length);
}
zipOutputStream.SetLevel(3); //0-9, 9 being the highest level of compression
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.Close();
zipOutputStream.CloseEntry();
zipOutputStream.IsStreamOwner = false;
}
memoryStream.Position = 0;
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)
{
var fileEntries = new List<FileEntry>();
using (var memoryStream = new MemoryStream(fileBytes))
{
var fileEntries = new List<FileEntry>();
var zipInputStream = new ZipInputStream(memoryStream);
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
using (var zipInputStream = new ZipInputStream(memoryStream))
{
var buffer = new byte[4096]; // 4K is optimum
using (var fileEntryMemoryStream = new MemoryStream())
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
{
StreamUtils.Copy(zipInputStream, fileEntryMemoryStream, buffer);
fileEntries.Add(new FileEntry(zipEntry.Name.EnsureStartsWith('/'), fileEntryMemoryStream.ToArray(), zipEntry.IsDirectory));
}
var buffer = new byte[4096]; // 4K is optimum
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);

Loading…
Cancel
Save