fixed zip streaming

This commit is contained in:
2021-05-19 16:14:12 -04:00
parent 8ede035b2a
commit dec44cf623
2 changed files with 10 additions and 9 deletions

View File

@@ -91,7 +91,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId> <artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version> <version>3.6.1</version>
<configuration> <configuration>
<goalPrefix>amp</goalPrefix> <goalPrefix>amp</goalPrefix>
</configuration> </configuration>

View File

@@ -1,10 +1,10 @@
package com.inteligr8.alfresco.amp; package com.inteligr8.alfresco.amp;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
@@ -93,7 +93,7 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
public void execute() throws MojoExecutionException { public void execute() throws MojoExecutionException {
if (this.skip) { if (this.skip) {
this.getLog().debug("Skipped AMP packaging"); this.getLog().debug("Skipped AMP package");
return; return;
} }
this.getLog().debug("Executing AMP packaging"); this.getLog().debug("Executing AMP packaging");
@@ -273,11 +273,12 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
zstream.putNextEntry(new ZipEntry(filename)); zstream.putNextEntry(new ZipEntry(filename));
File file = new File(directory, filename); File file = new File(directory, filename);
FileReader freader = new FileReader(file); FileInputStream fistream = new FileInputStream(file);
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
try { try {
IOUtil.copy(freader, zstream); IOUtil.copy(bistream, zstream);
} finally { } finally {
freader.close(); bistream.close();
} }
zstream.closeEntry(); zstream.closeEntry();
@@ -300,13 +301,13 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
zstream.putNextEntry(new ZipEntry(targetPath + file.getName())); zstream.putNextEntry(new ZipEntry(targetPath + file.getName()));
FileInputStream fistream = new FileInputStream(file); FileInputStream fistream = new FileInputStream(file);
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
try { try {
IOUtil.copy(fistream, zstream); IOUtil.copy(bistream, zstream);
} finally { } finally {
fistream.close(); bistream.close();
} }
zstream.flush();
zstream.closeEntry(); zstream.closeEntry();
} }