Skip to content

Commit

Permalink
Improve image loading
Browse files Browse the repository at this point in the history
  • Loading branch information
giftkugel committed Aug 29, 2024
1 parent 922de17 commit b016b00
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,24 @@ func (config *Config) Setup() error {
if config.UI.LogoImage != "" {
file, fileError := os.Open(config.UI.LogoImage)
if fileError != nil {
panic(fileError)
return fileError
}
defer func(file *os.File) {
err := file.Close()
if err != nil {
panic(err)
fileCloseError := file.Close()
if fileCloseError != nil {
panic(fileCloseError)
}
}(file)

// Get the file size
stat, err := file.Stat()
if err != nil {
panic(err)
stat, statError := file.Stat()
if statError != nil {
return statError
}

// Read the file into a byte slice
bs := make([]byte, stat.Size())
_, err = bufio.NewReader(file).Read(bs)
if err != nil && err != io.EOF {
panic(err)
_, bufferError := bufio.NewReader(file).Read(bs)
if bufferError != nil && bufferError != io.EOF {
return bufferError
}

log.Info("Own logo loaded from %s", config.UI.LogoImage)
Expand Down

0 comments on commit b016b00

Please sign in to comment.