GetAudio: avoid leaking goroutine on cancellation
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
54e9bc0d2c
commit
a8ba36a0e1
|
@ -173,25 +173,14 @@ func (s *audioGetterState) getAudio(ctx context.Context, r io.ReadCloser, mediaS
|
||||||
})
|
})
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
|
defer func() { _ = r.Close() }()
|
||||||
|
defer func() { _ = uploadWriter.Close() }()
|
||||||
|
defer func() { _ = ffmpegWriter.Close() }()
|
||||||
|
|
||||||
if _, err := io.Copy(mw, streamWithProgress); err != nil {
|
if _, err := io.Copy(mw, streamWithProgress); err != nil {
|
||||||
return fmt.Errorf("error copying: %v", err)
|
return fmt.Errorf("error copying: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignoring the following Close errors should be ok, as the Copy has
|
|
||||||
// already completed successfully.
|
|
||||||
|
|
||||||
if err := ffmpegWriter.Close(); err != nil {
|
|
||||||
s.logger.With("err", err).Warn("getAudio: unable to close ffmpegWriter")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := uploadWriter.Close(); err != nil {
|
|
||||||
s.logger.With("err", err).Warn("getAudio: unable to close pipeWriter")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := r.Close(); err != nil {
|
|
||||||
s.logger.With("err", err).Warn("getAudio: unable to close stream")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue