Skip to content

Commit

Permalink
nsq_to_file: check and exit on errors for file-related operations
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiferson committed Jan 3, 2019
1 parent c338db0 commit 0d4b61d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/nsq_to_file/file_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,19 @@ func (f *FileLogger) Close() {
}

if f.gzipWriter != nil {
f.gzipWriter.Close()
err := f.gzipWriter.Close()
if err != nil {
log.Fatalf("ERROR: failed to close GZIP writer: %s", err)
}
}
err := f.out.Sync()
if err != nil {
log.Fatalf("ERROR: failed to fsync output file: %s", err)
}
err = f.out.Close()
if err != nil {
log.Fatalf("ERROR: failed to close output file: %s", err)
}
f.out.Sync()
f.out.Close()

// Move file from work dir to output dir if necessary, taking care not
// to overwrite existing files
Expand Down

0 comments on commit 0d4b61d

Please sign in to comment.