Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to allow output to be a gzip file #16

Closed

Conversation

kiwi1969
Copy link

Changes to allow output to be a gzip file (if the filename ends with ".gz")

Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
@alexgubanow
Copy link

alexgubanow commented Mar 27, 2024

please target "release-5.0.1" branch first
do the change less invasive, like removal try{} is no go
branch name has to be created from issue, so it will be reflected in issue log

Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
Restored try clause.
Increased GZIP buffer size for effciency and for CryptoCards that only get used if buffer > = 8192 bytes
Set GZIP flush option to prevent corruption of file on last write

Signed-off-by: Russell Shaw <69813534+kiwi1969@users.noreply.github.com>
@kiwi1969
Copy link
Author

Updated code as suggested. Added buffer=8192 and syncflush parms to open of gzip file, so last record is written , and file is not corrupt.
Not sure how to create branch from issue - I cannot find such an option

@@ -95,15 +99,23 @@ else if (outputFileName == null)
printUsageAndExit();
}

System.out.println("Attempting to decompress input file (" + inputFileName +") to output file (" + outputFileName +")");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code below has duplicate lines, which may lead to errors later. more cleaner solution would be to create an object of FileOutputStream, while GZIPOutputStream is overload of such.

Suggested change
var outputStream = null;
try {
if (outputFileName.endsWith(".gz")) {
outputStream = new GZIPOutputStream(new FileOutputStream(outputFileName), 8192, true);
}
else {
outputStream = new FileOutputStream(outputFileName);
}
}
try (TerseDecompresser outputWriter = TerseDecompresser.create(new FileInputStream(inputFileName), outputStream ))
{
outputWriter.TextFlag = textMode;
outputWriter.decode();
}

suggested code is just to describe the idea, please test it

@kiwi1969 kiwi1969 closed this Mar 27, 2024
@kiwi1969 kiwi1969 deleted the kiwi1969-patch-1 branch March 27, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants