Browse Source

return an error in case configuration file can't be opened (#1920)

pull/1923/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
083151360e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      internal/conf/conf.go

3
internal/conf/conf.go

@ -4,6 +4,7 @@ package conf
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"os" "os"
"sort" "sort"
@ -43,7 +44,7 @@ func loadFromFile(fpath string, conf *Conf) (bool, error) {
// mediamtx.yml is optional // mediamtx.yml is optional
// other configuration files are not // other configuration files are not
if fpath == "mediamtx.yml" || fpath == "rtsp-simple-server.yml" { if fpath == "mediamtx.yml" || fpath == "rtsp-simple-server.yml" {
if _, err := os.Stat(fpath); err != nil { if _, err := os.Stat(fpath); errors.Is(err, os.ErrNotExist) {
conf.UnmarshalJSON(nil) // load defaults conf.UnmarshalJSON(nil) // load defaults
return false, nil return false, nil
} }

Loading…
Cancel
Save