From deb7c330894d87803da74ac8fc2be4f5d8a8d45b Mon Sep 17 00:00:00 2001 From: Matt Reiferson Date: Thu, 3 Jan 2019 09:23:23 -0800 Subject: [PATCH] nsq_to_file: don't open multiple GZIP streams This changes the structure of output files to be continuous GZIP streams rather than concatenated GZIP streams. This is likely slightly more compatible and expected. --- apps/nsq_to_file/file_logger.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/nsq_to_file/file_logger.go b/apps/nsq_to_file/file_logger.go index 5f9e23ffb..c46d0a0f7 100644 --- a/apps/nsq_to_file/file_logger.go +++ b/apps/nsq_to_file/file_logger.go @@ -211,16 +211,13 @@ func (f *FileLogger) Write(p []byte) (n int, err error) { } func (f *FileLogger) Sync() error { - var err error if f.gzipWriter != nil { - f.gzipWriter.Close() - err = f.out.Sync() - f.gzipWriter, _ = gzip.NewWriterLevel(f, f.opts.GZIPLevel) - f.writer = f.gzipWriter - } else { - err = f.out.Sync() + err := f.gzipWriter.Flush() + if err != nil { + return err + } } - return err + return f.out.Sync() } func (f *FileLogger) calculateCurrentFilename() string {