Skip to content

Commit

Permalink
Skip output size check in special cases
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Apr 22, 2024
1 parent 0eeaad6 commit df84d85
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion v2/app/BlockCompressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ func (this *fileCompressTask) call() (int, uint64, uint64) {
// Close will return an error if it has already been called.
// The deferred call does not check for error.
if err := input.Close(); err != nil {
log.Println("Warning: %v\n", err)
msg := fmt.Sprintf("Warning: %v\n", err)
log.Println(msg, verbosity > 0)
}

// Delete input file
Expand Down
19 changes: 16 additions & 3 deletions v2/app/BlockDecompressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,24 @@ func (this *fileDecompressTask) call() (int, uint64) {

overwrite := this.ctx["overwrite"].(bool)
var output io.WriteCloser
checkOutputSize := true

if runtime.GOOS == "windows" {
if strings.EqualFold(outputName, "NUL") {
checkOutputSize = false
}
} else {
if strings.EqualFold(outputName, "/DEV/NULL") {
checkOutputSize = false
}
}

if strings.EqualFold(outputName, _DECOMP_NONE) {
output, _ = kio.NewNullOutputStream()
checkOutputSize = false
} else if strings.EqualFold(outputName, _DECOMP_STDOUT) {
output = os.Stdout
checkOutputSize = false
} else {
var err error

Expand Down Expand Up @@ -628,7 +641,6 @@ func (this *fileDecompressTask) call() (int, uint64) {
// Close streams to ensure all data are flushed
// Deferred close is fallback for error paths
if err := cis.Close(); err != nil {
fmt.Printf("%v\n", err)
return kanzi.ERR_PROCESS_BLOCK, uint64(decoded)
}

Expand All @@ -640,7 +652,7 @@ func (this *fileDecompressTask) call() (int, uint64) {
_, hasTo := this.ctx["to"]
_, hasFrom := this.ctx["from"]

if hasTo == false && hasFrom == false {
if checkOutputSize == true && hasTo == false && hasFrom == false {
if osz, prst := this.ctx["outputSize"]; prst == true {
outputSize := osz.(int64)

Expand Down Expand Up @@ -692,7 +704,8 @@ func (this *fileDecompressTask) call() (int, uint64) {
// Close will return an error if it has already been called.
// The deferred call does not check for error.
if err := input.Close(); err != nil {
log.Println("Warning: %v\n", err)
msg := fmt.Sprintf("Warning: %v\n", err)
log.Println(msg, verbosity > 0)
}

// Delete input file
Expand Down

0 comments on commit df84d85

Please sign in to comment.