Skip to content

Commit

Permalink
Use switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
seanavery committed Sep 24, 2024
1 parent 5ea33fc commit 242a187
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cam/cam.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ func (vs *videostore) DoCommand(_ context.Context, command map[string]interface{
// It waits for the segment duration before running to ensure the last segment
// is written to storage before concatenation.
// TODO: (seanp) Optimize this to immediately run as soon as the current segment is completed.
if async {
switch async {
case true:
vs.logger.Debug("running save command asynchronously")
go func() {
time.Sleep(vs.conc.segmentDur)
Expand All @@ -293,16 +294,17 @@ func (vs *videostore) DoCommand(_ context.Context, command map[string]interface{
"filename": uploadFileName,
"status": "async",
}, nil
default:
err = vs.conc.concat(from, to, uploadFilePath)
if err != nil {
vs.logger.Error("failed to concat files ", err)
return nil, err
}
return map[string]interface{}{
"command": "save",
"filename": uploadFileName,
}, nil
}
err = vs.conc.concat(from, to, uploadFilePath)
if err != nil {
vs.logger.Error("failed to concat files ", err)
return nil, err
}
return map[string]interface{}{
"command": "save",
"filename": uploadFileName,
}, nil
case "fetch":
vs.logger.Debug("fetch command received")
from, to, err := validateFetchCommand(command)
Expand Down

0 comments on commit 242a187

Please sign in to comment.