0

Some linter cleanup

This commit is contained in:
Gabe Kangas 2021-06-29 10:21:00 -07:00
parent ab3bbd59bf
commit 12104978e8
10 changed files with 19 additions and 19 deletions

View File

@ -10,7 +10,7 @@ import (
// DatabaseFilePath is the path to the file ot be used as the global database for this run of the application. // DatabaseFilePath is the path to the file ot be used as the global database for this run of the application.
var DatabaseFilePath = "data/owncast.db" var DatabaseFilePath = "data/owncast.db"
// LogDirectory is the path to various log files // LogDirectory is the path to various log files.
var LogDirectory = "./data/logs" var LogDirectory = "./data/logs"
// EnableDebugFeatures will print additional data to help in debugging. // EnableDebugFeatures will print additional data to help in debugging.

View File

@ -52,7 +52,7 @@ func VerifyFFMpegPath(path string) error {
versionString := "v" + strings.Split(fullVersionString, "-")[0] versionString := "v" + strings.Split(fullVersionString, "-")[0]
// Some builds of ffmpeg have wierd build numbers that we can't parse // Some builds of ffmpeg have weird build numbers that we can't parse
if !semver.IsValid(versionString) { if !semver.IsValid(versionString) {
log.Debugf("unable to determine if ffmpeg version %s is recent enough. if you experience issues with video you may want to look into updating", fullVersionString) log.Debugf("unable to determine if ffmpeg version %s is recent enough. if you experience issues with video you may want to look into updating", fullVersionString)
return nil return nil

View File

@ -35,7 +35,7 @@ func SetTags(w http.ResponseWriter, r *http.Request) {
return return
} }
var tagStrings []string tagStrings := make([]string, 0)
for _, tag := range configValues { for _, tag := range configValues {
tagStrings = append(tagStrings, tag.Value.(string)) tagStrings = append(tagStrings, tag.Value.(string))
} }
@ -226,7 +226,7 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
} }
imgPath := filepath.Join("data", "logo"+extension) imgPath := filepath.Join("data", "logo"+extension)
if err := ioutil.WriteFile(imgPath, bytes, 0644); err != nil { if err := ioutil.WriteFile(imgPath, bytes, 0600); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error()) controllers.WriteSimpleResponse(w, false, err.Error())
return return
} }
@ -434,7 +434,6 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
if newS3Config.Value.Endpoint == "" || !utils.IsValidUrl((newS3Config.Value.Endpoint)) { if newS3Config.Value.Endpoint == "" || !utils.IsValidUrl((newS3Config.Value.Endpoint)) {
controllers.WriteSimpleResponse(w, false, "s3 support requires an endpoint") controllers.WriteSimpleResponse(w, false, "s3 support requires an endpoint")
return return
} }
if newS3Config.Value.AccessKey == "" || newS3Config.Value.Secret == "" { if newS3Config.Value.AccessKey == "" || newS3Config.Value.Secret == "" {
@ -455,7 +454,6 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
data.SetS3Config(newS3Config.Value) data.SetS3Config(newS3Config.Value)
controllers.WriteSimpleResponse(w, true, "storage configuration changed") controllers.WriteSimpleResponse(w, true, "storage configuration changed")
} }
// SetStreamOutputVariants will handle the web config request to set the video output stream variants. // SetStreamOutputVariants will handle the web config request to set the video output stream variants.

View File

@ -15,7 +15,7 @@ type variantsResponse struct {
Index int `json:"index"` Index int `json:"index"`
} }
// GetVideoStreamOutputVariants will return the video variants available, // GetVideoStreamOutputVariants will return the video variants available.
func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) { func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
outputVariants := data.GetStreamOutputVariants() outputVariants := data.GetStreamOutputVariants()
result := make([]variantsResponse, len(outputVariants)) result := make([]variantsResponse, len(outputVariants))

View File

@ -199,7 +199,7 @@ func GetHTTPListenAddress() string {
log.Traceln(httpListenAddressKey, err) log.Traceln(httpListenAddressKey, err)
return config.GetDefaults().WebServerIP return config.GetDefaults().WebServerIP
} }
return string(address) return address
} }
// SetHTTPListenAddress will set the server HTTP listen address. // SetHTTPListenAddress will set the server HTTP listen address.
@ -577,7 +577,7 @@ func FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) int {
return indexedQualities[0].index return indexedQualities[0].index
} }
// GetUsernameBlocklist will return the blocked usernames as a comma seperated string. // GetUsernameBlocklist will return the blocked usernames as a comma separated string.
func GetUsernameBlocklist() string { func GetUsernameBlocklist() string {
usernameString, err := _datastore.GetString(blockedUsernamesKey) usernameString, err := _datastore.GetString(blockedUsernamesKey)
@ -589,7 +589,7 @@ func GetUsernameBlocklist() string {
return usernameString return usernameString
} }
// SetUsernameBlocklist set the username blocklist as a comma seperated string. // SetUsernameBlocklist set the username blocklist as a comma separated string.
func SetUsernameBlocklist(usernames string) error { func SetUsernameBlocklist(usernames string) error {
return _datastore.SetString(blockedUsernamesKey, usernames) return _datastore.SetString(blockedUsernamesKey, usernames)
} }

View File

@ -113,7 +113,7 @@ func SetStreamAsDisconnected() {
} }
variantPlaylist := playlist.(*m3u8.MediaPlaylist) variantPlaylist := playlist.(*m3u8.MediaPlaylist)
if len(variantPlaylist.Segments) > int(data.GetStreamLatencyLevel().SegmentCount) { if len(variantPlaylist.Segments) > data.GetStreamLatencyLevel().SegmentCount {
variantPlaylist.Segments = variantPlaylist.Segments[:len(variantPlaylist.Segments)] variantPlaylist.Segments = variantPlaylist.Segments[:len(variantPlaylist.Segments)]
} }

View File

@ -14,7 +14,7 @@ import (
// in the stream. // in the stream.
func CleanupOldContent(baseDirectory string) { func CleanupOldContent(baseDirectory string) {
// Determine how many files we should keep on disk // Determine how many files we should keep on disk
maxNumber := int(data.GetStreamLatencyLevel().SegmentCount) maxNumber := data.GetStreamLatencyLevel().SegmentCount
buffer := 10 buffer := 10
files, err := getAllFilesRecursive(baseDirectory) files, err := getAllFilesRecursive(baseDirectory)

View File

@ -25,13 +25,14 @@ type OCLogger struct {
} }
var Logger *OCLogger var Logger *OCLogger
var _level logrus.Level
// Setup configures our custom logging destinations. // Setup configures our custom logging destinations.
func Setup(enableDebugOptions bool, enableVerboseLogging bool) { func Setup(enableDebugOptions bool, enableVerboseLogging bool) {
// Create the logging directory if needed // Create the logging directory if needed
if !utils.DoesFileExists(getLogFilePath()) { if !utils.DoesFileExists(getLogFilePath()) {
os.Mkdir(getLogFilePath(), 0700) if err := os.Mkdir(getLogFilePath(), 0700); err != nil {
logger.Errorln("unable to create directory", getLogFilePath(), err)
}
} }
// Write logs to a file // Write logs to a file

View File

@ -18,7 +18,6 @@ import (
) )
func main() { func main() {
// Enable bundling of admin assets // Enable bundling of admin assets
_ = pkger.Include("/admin") _ = pkger.Include("/admin")
@ -48,7 +47,9 @@ func main() {
// Create the data directory if needed // Create the data directory if needed
if !utils.DoesFileExists("data") { if !utils.DoesFileExists("data") {
os.Mkdir("./data", 0700) if err := os.Mkdir("./data", 0700); err != nil {
log.Fatalln("Cannot create data directory", err)
}
} }
// Allows a user to restore a specific database backup // Allows a user to restore a specific database backup

View File

@ -22,18 +22,18 @@ func Restore(backupFile string, databaseFile string) error {
data, err := ioutil.ReadFile(backupFile) data, err := ioutil.ReadFile(backupFile)
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("Unable to read backup file %s", err)) return fmt.Errorf("Unable to read backup file %s", err)
} }
gz, err := gzip.NewReader(bytes.NewBuffer(data)) gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("Unable to read backup file %s", err)) return fmt.Errorf("Unable to read backup file %s", err)
} }
defer gz.Close() defer gz.Close()
var b bytes.Buffer var b bytes.Buffer
if _, err := io.Copy(&b, gz); err != nil { if _, err := io.Copy(&b, gz); err != nil {
return errors.New(fmt.Sprintf("Unable to read backup file %s", err)) return fmt.Errorf("Unable to read backup file %s", err)
} }
defer gz.Close() defer gz.Close()