Search additional dirs for the webui dir

This commit is contained in:
jamesread
2021-11-03 22:52:38 +00:00
parent 12475cd310
commit 3aa7c97bfb
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -23,12 +23,16 @@ type webUISettings struct {
func findWebuiDir() string {
directoriesToSearch := []string{
"./webui",
"/usr/share/OliveTin/webui/",
"/var/www/olivetin/",
"/etc/OliveTin/webui/",
}
for _, dir := range directoriesToSearch {
if _, err := os.Stat(dir); !os.IsNotExist(err) {
log.Infof("Found the webui directory here: %v", dir)
log.WithFields(log.Fields{
"dir": dir,
}).Infof("Found the webui directory")
return dir
}
+3
View File
@@ -3,9 +3,12 @@ package httpservers
import (
"github.com/stretchr/testify/assert"
"testing"
"os"
)
func TestGetWebuiDir(t *testing.T) {
os.Chdir("../../") // go test sets the cwd to "httpservers" by default
dir := findWebuiDir()
assert.Equal(t, "./webui", dir, "Finding the webui dir")