style fix for error checking (#1170)

+additional linting
This commit is contained in:
Meisam
2021-07-09 20:16:44 +02:00
committed by GitHub
parent a13e1e75e2
commit 7361578412
22 changed files with 62 additions and 112 deletions

View File

@@ -74,8 +74,7 @@ func (s *FileWriterReceiverService) uploadHandler(w http.ResponseWriter, r *http
}
defer f.Close()
_, err = f.Write(data)
if err != nil {
if _, err := f.Write(data); err != nil {
returnError(err, w)
return
}

View File

@@ -99,7 +99,7 @@ func (t *Transcoder) Start() {
_commandExec = exec.Command("sh", "-c", command)
if t.stdin != nil {
_commandExec.Stdin = t.stdin
_commandExec.Stdin = t.stdin
}
stdout, err := _commandExec.StderrPipe()
@@ -107,8 +107,7 @@ func (t *Transcoder) Start() {
panic(err)
}
err = _commandExec.Start()
if err != nil {
if err := _commandExec.Start(); err != nil {
log.Errorln("Transcoder error. See ", logging.GetTranscoderLogFilePath(), " for full output to debug.")
log.Panicln(err, command)
}

View File

@@ -94,31 +94,27 @@ func createVariantDirectories() {
// Create private hls data dirs
utils.CleanupDirectory(config.PublicHLSStoragePath)
utils.CleanupDirectory(config.PrivateHLSStoragePath)
if len(data.GetStreamOutputVariants()) != 0 {
for index := range data.GetStreamOutputVariants() {
err := os.MkdirAll(path.Join(config.PrivateHLSStoragePath, strconv.Itoa(index)), 0777)
if err != nil {
if err := os.MkdirAll(path.Join(config.PrivateHLSStoragePath, strconv.Itoa(index)), 0777); err != nil {
log.Fatalln(err)
}
dir := path.Join(config.PublicHLSStoragePath, strconv.Itoa(index))
log.Traceln("Creating", dir)
err = os.MkdirAll(dir, 0777)
if err != nil {
if err := os.MkdirAll(dir, 0777); err != nil {
log.Fatalln(err)
}
}
} else {
dir := path.Join(config.PrivateHLSStoragePath, strconv.Itoa(0))
log.Traceln("Creating", dir)
err := os.MkdirAll(dir, 0777)
if err != nil {
if err := os.MkdirAll(dir, 0777); err != nil {
log.Fatalln(err)
}
dir = path.Join(config.PublicHLSStoragePath, strconv.Itoa(0))
log.Traceln("Creating", dir)
err = os.MkdirAll(dir, 0777)
if err != nil {
if err := os.MkdirAll(dir, 0777); err != nil {
log.Fatalln(err)
}
}