Unverified Commit 51f8ca32 authored by Fabien Viale's avatar Fabien Viale Committed by GitHub
Browse files

Merge pull request #3772 from fviale/master

ZipUtils: do not perform compression in memory
parents 2c18b2b2 20eccc8d
......@@ -73,26 +73,22 @@ public class ZipUtils extends FileUtils {
* @throws IOException if the zip file cannot be created.
public static void zip(String[] directoriesAndFiles, File dest, CRC32 crc) throws IOException {
byte[] zipped = ZipUtils.zipDirectoriesAndFiles(directoriesAndFiles, crc);
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest))) {
try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(dest)))) {
ZipUtils.zipDirectoriesAndFiles(zos, directoriesAndFiles, crc);
* Create a zip file that contains all the directory listed in directories parameter.
* @param zos output stream destination
* @param directoriesAndFiles the list of directories and files to be zipped.
* @param crc the CRC32 of all zipentries. Can be null if no crc is needed.
* @throws IOException if the zip file cannot be created.
* @return the zip file as a byte[].
* @throws IOException if an error occurs during the compression
public static byte[] zipDirectoriesAndFiles(String[] directoriesAndFiles, CRC32 crc) throws IOException {
// Fill in a byte array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
public static void zipDirectoriesAndFiles(ZipOutputStream zos, String[] directoriesAndFiles, CRC32 crc)
throws IOException {
// Create zip stream
ZipOutputStream zos = new ZipOutputStream(baos);
// zip file is ready
......@@ -100,10 +96,6 @@ public class ZipUtils extends FileUtils {
// Close the file output streams
return baos.toByteArray();
......@@ -104,6 +104,8 @@ public class SchedulerBackupRunner implements Runnable {
} finally {
LOGGER.info("Backup terminated");
private boolean noTaskIsRunning() {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment