Skip to content

Commit

Permalink
Correct size for gz file (#777)
Browse files Browse the repository at this point in the history
Fix #775 

When we are using .gz for output we are counting incorrect file size. Now it should be ok
  • Loading branch information
slimus authored Jun 23, 2020
1 parent f364a39 commit 550c73e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions output_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,19 @@ func (o *FileOutput) Write(data []byte) (n int, err error) {
o.queueLength = 0
}

o.writer.Write(data)
o.writer.Write([]byte(payloadSeparator))
n, _ = o.writer.Write(data)
nSeparator, _ := o.writer.Write([]byte(payloadSeparator))

o.totalFileSize += int64(len(data) + len(payloadSeparator))
n += nSeparator

o.totalFileSize += int64(n)
o.queueLength++

if Settings.outputFileConfig.outputFileMaxSize > 0 && o.totalFileSize >= Settings.outputFileConfig.outputFileMaxSize {
return len(data), errors.New("File output reached size limit")
return n, errors.New("File output reached size limit")
}

return len(data), nil
return n, nil
}

func (o *FileOutput) flush() {
Expand Down

0 comments on commit 550c73e

Please sign in to comment.