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.
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"
// 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]
// 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) {
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

View file

@ -35,7 +35,7 @@ func SetTags(w http.ResponseWriter, r *http.Request) {
return
}
var tagStrings []string
tagStrings := make([]string, 0)
for _, tag := range configValues {
tagStrings = append(tagStrings, tag.Value.(string))
}
@ -226,7 +226,7 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
}
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())
return
}
@ -434,7 +434,6 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
if newS3Config.Value.Endpoint == "" || !utils.IsValidUrl((newS3Config.Value.Endpoint)) {
controllers.WriteSimpleResponse(w, false, "s3 support requires an endpoint")
return
}
if newS3Config.Value.AccessKey == "" || newS3Config.Value.Secret == "" {
@ -455,7 +454,6 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
data.SetS3Config(newS3Config.Value)
controllers.WriteSimpleResponse(w, true, "storage configuration changed")
}
// 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"`
}
// GetVideoStreamOutputVariants will return the video variants available,
// GetVideoStreamOutputVariants will return the video variants available.
func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
outputVariants := data.GetStreamOutputVariants()
result := make([]variantsResponse, len(outputVariants))

View file

@ -199,7 +199,7 @@ func GetHTTPListenAddress() string {
log.Traceln(httpListenAddressKey, err)
return config.GetDefaults().WebServerIP
}
return string(address)
return address
}
// SetHTTPListenAddress will set the server HTTP listen address.
@ -577,7 +577,7 @@ func FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) int {
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 {
usernameString, err := _datastore.GetString(blockedUsernamesKey)
@ -589,7 +589,7 @@ func GetUsernameBlocklist() string {
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 {
return _datastore.SetString(blockedUsernamesKey, usernames)
}

View file

@ -113,7 +113,7 @@ func SetStreamAsDisconnected() {
}
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)]
}

View file

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

View file

@ -25,13 +25,14 @@ type OCLogger struct {
}
var Logger *OCLogger
var _level logrus.Level
// Setup configures our custom logging destinations.
func Setup(enableDebugOptions bool, enableVerboseLogging bool) {
// Create the logging directory if needed
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

View file

@ -18,7 +18,6 @@ import (
)
func main() {
// Enable bundling of admin assets
_ = pkger.Include("/admin")
@ -48,7 +47,9 @@ func main() {
// Create the data directory if needed
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

View file

@ -22,18 +22,18 @@ func Restore(backupFile string, databaseFile string) error {
data, err := ioutil.ReadFile(backupFile)
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))
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()
var b bytes.Buffer
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()