-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* changed archiving to Apache Commons Compress (fixed reading all byt…
…es out of memory bug) * fixed log deletion on Windows * added max heap to sh and bat * added release notes and tag version to Github workflows * added version to instrument.yml
- Loading branch information
1 parent
abea5bc
commit 3afded6
Showing
11 changed files
with
93 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
api/src/main/kotlin/org/dxworks/voyager/api/instruments/config/InstrumentConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
java -jar dx-voyager.jar %* | ||
java -Xmx8g -jar dx-voyager.jar %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
java -jar dx-voyager.jar "$@" | ||
java -Xmx8g -jar dx-voyager.jar "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 32 additions & 33 deletions
65
dx-voyager/src/main/kotlin/org/dxworks/voyager/zip/Zipper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,53 @@ | ||
package org.dxworks.voyager.zip | ||
|
||
import org.apache.commons.compress.archivers.ArchiveOutputStream | ||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry | ||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream | ||
import org.apache.commons.compress.utils.IOUtils | ||
import org.dxworks.voyager.results.FileAndAlias | ||
import org.dxworks.voyager.utils.logger | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import java.io.FileOutputStream | ||
import java.util.zip.ZipEntry | ||
import java.util.zip.ZipOutputStream | ||
import java.io.IOException | ||
|
||
|
||
class Zipper { | ||
companion object { | ||
private val log = logger<Zipper>() | ||
} | ||
|
||
fun zipFiles(files: List<FileAndAlias>, zipPath: String) { | ||
val fos = FileOutputStream(zipPath) | ||
val zipOut = ZipOutputStream(fos) | ||
files.forEach { | ||
zipFile(it.file, it.alias, zipOut) | ||
fun zipFiles(files: List<FileAndAlias>, zipPath: String): List<FileAndAlias> { | ||
return ZipArchiveOutputStream(FileOutputStream(zipPath)).use { archive -> | ||
files.filter { | ||
zipFile(it.file, it.alias, archive) | ||
} | ||
} | ||
zipOut.close() | ||
fos.close() | ||
} | ||
|
||
private fun zipFile(fileToZip: File, fileName: String, zipOut: ZipOutputStream) { | ||
if (fileToZip.isDirectory) { | ||
zipOut.putNextEntry( | ||
ZipEntry( | ||
if (fileName.endsWith("/")) { | ||
fileName | ||
} else { | ||
"$fileName/" | ||
} | ||
) | ||
) | ||
zipOut.closeEntry() | ||
|
||
fileToZip.listFiles()?.forEach { | ||
zipFile(it, fileName + "/" + it.name, zipOut) | ||
} | ||
|
||
return | ||
private fun zipFile(file: File, fileName: String, archive: ArchiveOutputStream): Boolean { | ||
if (file.isDirectory) { | ||
return file.listFiles()?.all { | ||
zipFile(it, fileName + "/" + it.name, archive) | ||
} ?: true | ||
} | ||
if (!fileToZip.exists()) { | ||
log.warn("File ${fileToZip.path} does not exist") | ||
if (!file.exists()) { | ||
log.warn("File ${file.path} does not exist") | ||
return false | ||
} else { | ||
val zipEntry = ZipEntry(fileName) | ||
zipOut.putNextEntry(zipEntry) | ||
val bytes = fileToZip.readBytes() | ||
zipOut.write(bytes, 0, bytes.size) | ||
val entry = ZipArchiveEntry(file, fileName) | ||
return try { | ||
FileInputStream(file).use { fis -> | ||
archive.putArchiveEntry(entry) | ||
IOUtils.copy(fis, archive) | ||
archive.closeArchiveEntry() | ||
} | ||
true | ||
} catch (e: IOException) { | ||
log.error("Could not zip file ${file.absolutePath}", e) | ||
false | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* changed archiving to Apache Commons Compress (fixed reading all bytes out of memory bug) | ||
* fixed log deletion on Windows | ||
* added max heap to sh and bat | ||
* added release notes and tag version to Github workflows | ||
* added version to instrument.yml |