fix(transcode): don't leave half transcode cache files lying around

fixes #270
This commit is contained in:
sentriz
2022-12-12 18:56:20 +00:00
parent b47c880ea5
commit ce31310571
2 changed files with 7 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ func NewFFmpegTranscoder() *FFmpegTranscoder {
return &FFmpegTranscoder{}
}
var ErrFFmpegKilled = fmt.Errorf("ffmpeg was killed early")
var ErrFFmpegExit = fmt.Errorf("ffmpeg exited with non 0 status code")
func (*FFmpegTranscoder) Transcode(ctx context.Context, profile Profile, in string, out io.Writer) error {
@@ -32,7 +33,11 @@ func (*FFmpegTranscoder) Transcode(ctx context.Context, profile Profile, in stri
}
var exitErr *exec.ExitError
if err := cmd.Wait(); err != nil && !errors.As(err, &exitErr) {
switch err := cmd.Wait(); {
case errors.As(err, &exitErr):
return fmt.Errorf("waiting cmd: %v: %w", err, ErrFFmpegKilled)
case err != nil:
return fmt.Errorf("waiting cmd: %w", err)
}
if code := cmd.ProcessState.ExitCode(); code > 1 {