Skip to content

Commit

Permalink
Dont return early on close
Browse files Browse the repository at this point in the history
  • Loading branch information
seanavery committed Sep 6, 2024
1 parent e42f2e8 commit f649b48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cam/cam.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (vs *videostore) deleter(ctx context.Context) {
func (vs *videostore) Close(ctx context.Context) error {
err := vs.stream.Close(ctx)
if err != nil {
return err
vs.logger.Error("failed to close stream", err)
}
vs.workers.Stop()
vs.enc.close()
Expand Down
10 changes: 8 additions & 2 deletions cam/concater.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ func (c *concater) concat(from, to time.Time, metadata string) (string, error) {
return outputPath, nil
}

// close closes the concater and removes the concat file.
// Do not need to clean up FFmpeg resources as they are handled in the concat function.
func (c *concater) close() {
c.concatFile.Close()
os.Remove(c.concatFile.Name())
if err := c.concatFile.Close(); err != nil {
c.logger.Error("failed to close concat file", err)
}
if err := os.Remove(c.concatFile.Name()); err != nil {
c.logger.Error("failed to remove concat file", err)
}
}

0 comments on commit f649b48

Please sign in to comment.