From 6b4b720bc824b4c73877d5baf71b0e603469fbc1 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sun, 6 Jan 2019 12:52:07 -0500 Subject: [PATCH] Revert "nsq_to_file: don't open multiple GZIP streams" This reverts commit 5ea1012443c194b62a10b05a80d7d897f35f77e8. also some further tweaks due to FileLogger refactor --- apps/nsq_to_file/file_logger.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/nsq_to_file/file_logger.go b/apps/nsq_to_file/file_logger.go index bc9571ad1..4fe77b009 100644 --- a/apps/nsq_to_file/file_logger.go +++ b/apps/nsq_to_file/file_logger.go @@ -229,13 +229,19 @@ func (f *FileLogger) Write(p []byte) (int, error) { } func (f *FileLogger) Sync() error { + var err error if f.gzipWriter != nil { - err := f.gzipWriter.Flush() + err = f.gzipWriter.Close() if err != nil { return err } + err = f.out.Sync() + f.gzipWriter, _ = gzip.NewWriterLevel(f.out, f.opts.GZIPLevel) + f.writer = f.gzipWriter + } else { + err = f.out.Sync() } - return f.out.Sync() + return err } func (f *FileLogger) currentFilename() string {