Cleanup some warnings

This commit is contained in:
Gabe Kangas 2022-06-20 22:36:01 -07:00
parent 718d6d312b
commit 86305c3028
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
2 changed files with 12 additions and 7 deletions

View File

@ -8,6 +8,11 @@ import (
"github.com/owncast/owncast/utils" "github.com/owncast/owncast/utils"
) )
const (
contentTypeJPEG = "image/jpeg"
contentTypeGIF = "image/gif"
)
// GetThumbnail will return the thumbnail image as a response. // GetThumbnail will return the thumbnail image as a response.
func GetThumbnail(w http.ResponseWriter, r *http.Request) { func GetThumbnail(w http.ResponseWriter, r *http.Request) {
imageFilename := "thumbnail.jpg" imageFilename := "thumbnail.jpg"
@ -28,9 +33,8 @@ func GetThumbnail(w http.ResponseWriter, r *http.Request) {
return return
} }
contentType := "image/jpeg"
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath) cacheTime := utils.GetCacheDurationSecondsForPath(imagePath)
writeBytesAsImage(imageBytes, contentType, w, cacheTime) writeBytesAsImage(imageBytes, contentTypeJPEG, w, cacheTime)
} }
// GetPreview will return the preview gif as a response. // GetPreview will return the preview gif as a response.
@ -53,7 +57,6 @@ func GetPreview(w http.ResponseWriter, r *http.Request) {
return return
} }
contentType := "image/jpeg"
cacheTime := utils.GetCacheDurationSecondsForPath(imagePath) cacheTime := utils.GetCacheDurationSecondsForPath(imagePath)
writeBytesAsImage(imageBytes, contentType, w, cacheTime) writeBytesAsImage(imageBytes, contentTypeGIF, w, cacheTime)
} }

View File

@ -1,7 +1,6 @@
package data package data
import ( import (
"errors"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
@ -12,6 +11,7 @@ import (
"github.com/owncast/owncast/models" "github.com/owncast/owncast/models"
"github.com/owncast/owncast/static" "github.com/owncast/owncast/static"
"github.com/owncast/owncast/utils" "github.com/owncast/owncast/utils"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@ -587,9 +587,11 @@ func VerifySettings() error {
if !utils.DoesFileExists(filepath.Join(config.DataDirectory, logoPath)) { if !utils.DoesFileExists(filepath.Join(config.DataDirectory, logoPath)) {
log.Traceln(logoPath, "not found in the data directory. copying a default logo.") log.Traceln(logoPath, "not found in the data directory. copying a default logo.")
logo := static.GetLogo() logo := static.GetLogo()
os.WriteFile(filepath.Join(config.DataDirectory, "logo.png"), logo, 0o600) if err := os.WriteFile(filepath.Join(config.DataDirectory, "logo.png"), logo, 0o600); err != nil {
return errors.Wrap(err, "failed to write logo to disk")
}
if err := SetLogoPath("logo.png"); err != nil { if err := SetLogoPath("logo.png"); err != nil {
log.Errorln("unable to set default logo to logo.svg", err) return errors.Wrap(err, "failed to save logo filename")
} }
} }