🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Don't cancel transcoding session if context is canceled
Deluan05c6cdea1ae7
diff --git a/core/ffmpeg/ffmpeg.go b/core/ffmpeg/ffmpeg.goindex ed78e6314..bf6dafac0 100644--- a/core/ffmpeg/ffmpeg.go+++ b/core/ffmpeg/ffmpeg.go@@ -39,7 +39,7 @@ func (e *ffmpeg) ExtractImage(ctx context.Context, path string) (io.ReadCloser,func (e *ffmpeg) start(ctx context.Context, args []string) (io.ReadCloser, error) {log.Trace(ctx, "Executing ffmpeg command", "cmd", args)- j := &Cmd{ctx: ctx, args: args}+ j := &ffCmd{args: args}j.PipeReader, j.out = io.Pipe()err := j.start()if err != nil {@@ -49,16 +49,15 @@ func (e *ffmpeg) start(ctx context.Context, args []string) (io.ReadCloser, errorreturn j, nil}-type Cmd struct {+type ffCmd struct {*io.PipeReaderout *io.PipeWriter- ctx context.Contextargs []stringcmd *exec.Cmd}-func (j *Cmd) start() error {- cmd := exec.CommandContext(j.ctx, j.args[0], j.args[1:]...) // #nosec+func (j *ffCmd) start() error {+ cmd := exec.Command(j.args[0], j.args[1:]...) // #noseccmd.Stdout = j.outif log.CurrentLevel() >= log.LevelTrace {cmd.Stderr = os.Stderr@@ -73,7 +72,7 @@ func (j *Cmd) start() error {return nil}-func (j *Cmd) wait() {+func (j *ffCmd) wait() {if err := j.cmd.Wait(); err != nil {var exitErr *exec.ExitErrorif errors.As(err, &exitErr) {@@ -83,10 +82,6 @@ func (j *Cmd) wait() {}return}- if j.ctx.Err() != nil {- _ = j.out.CloseWithError(j.ctx.Err())- return- }_ = j.out.Close()}diff --git a/utils/cache/file_caches_test.go b/utils/cache/file_caches_test.goindex 67bbdf84d..5b5154c17 100644--- a/utils/cache/file_caches_test.go+++ b/utils/cache/file_caches_test.go@@ -120,31 +120,6 @@ var _ = Describe("File Caches", func() {// TODO How to make the fscache reader return the underlying reader error?//Expect(err).To(MatchError("read failure"))- // Data should not be cached (or eventually be removed from cache)- Eventually(func() bool {- s, _ = fc.Get(context.Background(), &testArg{"test"})- if s != nil {- return s.Cached- }- return false- }).Should(BeFalse())- })- })- When("context is canceled", func() {- It("does not cache", func() {- ctx, cancel := context.WithCancel(context.Background())- fc := callNewFileCache("test", "1KB", "test", 0, func(ctx context.Context, arg Item) (io.Reader, error) {- return &ctxFakeReader{ctx}, nil- })-- s, err := fc.Get(ctx, &testArg{"test"})- Expect(err).ToNot(HaveOccurred())- cancel()- b := make([]byte, 10)- _, err = s.Read(b)- // TODO Should be context.Canceled error- Expect(err).To(MatchError(io.EOF))-// Data should not be cached (or eventually be removed from cache)Eventually(func() bool {s, _ = fc.Get(context.Background(), &testArg{"test"})@@ -166,7 +141,3 @@ func (t *testArg) Key() string { return t.s }type errFakeReader struct{ err error }func (e errFakeReader) Read([]byte) (int, error) { return 0, e.err }--type ctxFakeReader struct{ ctx context.Context }--func (e *ctxFakeReader) Read([]byte) (int, error) { return 0, e.ctx.Err() }