Sfoglia il codice sorgente

Search additional dirs for the webui dir

jamesread 4 anni fa
parent
commit
3aa7c97bfb

+ 5 - 1
internal/httpservers/webuiServer.go

@@ -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 - 0
internal/httpservers/webuiServer_test.go

@@ -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")