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 {