This commit is contained in:
Graham Steffaniak 2023-09-02 19:16:19 -05:00
parent 33863f05c4
commit 99c8bf8036
6 changed files with 63 additions and 22 deletions

View File

@ -5,13 +5,15 @@ All notable changes to this project will be documented in this file. See [standa
# v0.2.0
- improved GUI
- improved UI
- more unified coehisive look
- Adjusted header bar look and icon behavior
- The shell is dead.
- If you need to use custom commands, exec into the docker container.
- All configuration is done via `filebrowser.yaml`
- Removed old code to migrate database veresions
- The json config file is dead.
- All configuration is done via advanced `filebrowser.yaml`
- The only flag that is allowed is flag to specify config file.
- Removed old code to migrate database versions
- Removed all unused cmd code
# v0.1.4

View File

@ -9,30 +9,34 @@ ok github.com/gtsteffaniak/filebrowser/diskcache 0.004s
? github.com/gtsteffaniak/filebrowser/errors [no test files]
? github.com/gtsteffaniak/filebrowser/files [no test files]
PASS
ok github.com/gtsteffaniak/filebrowser/fileutils 0.003s
2023/09/02 13:08:16 Error opening YAML file: open filebrowser.yaml: no such file or directory
exit status 1
FAIL github.com/gtsteffaniak/filebrowser/http 0.003s
ok github.com/gtsteffaniak/filebrowser/fileutils 0.004s
2023/09/02 19:15:20 h: 401 <nil>
2023/09/02 19:15:20 h: 401 <nil>
2023/09/02 19:15:20 h: 401 <nil>
2023/09/02 19:15:20 h: 401 <nil>
2023/09/02 19:15:20 h: 401 <nil>
2023/09/02 19:15:20 h: 401 <nil>
PASS
ok github.com/gtsteffaniak/filebrowser/img 0.123s
ok github.com/gtsteffaniak/filebrowser/http 0.094s
PASS
ok github.com/gtsteffaniak/filebrowser/rules 0.003s
2023/09/02 13:08:16 Error opening YAML file: open filebrowser.yaml: no such file or directory
exit status 1
FAIL github.com/gtsteffaniak/filebrowser/runner 0.002s
ok github.com/gtsteffaniak/filebrowser/img 0.122s
PASS
ok github.com/gtsteffaniak/filebrowser/rules 0.002s
PASS
ok github.com/gtsteffaniak/filebrowser/runner 0.004s
goos: linux
goarch: amd64
pkg: github.com/gtsteffaniak/filebrowser/search
cpu: 11th Gen Intel(R) Core(TM) i5-11320H @ 3.20GHz
BenchmarkSearchAllIndexes-8 10 5705789 ns/op 3017139 B/op 44605 allocs/op
BenchmarkFillIndex-8 10 3205461 ns/op 18498 B/op 454 allocs/op
BenchmarkSearchAllIndexes-8 10 5176084 ns/op 2743632 B/op 42785 allocs/op
BenchmarkFillIndex-8 10 3263308 ns/op 18485 B/op 453 allocs/op
PASS
ok github.com/gtsteffaniak/filebrowser/search 0.117s
? github.com/gtsteffaniak/filebrowser/settings [no test files]
ok github.com/gtsteffaniak/filebrowser/search 0.109s
PASS
ok github.com/gtsteffaniak/filebrowser/settings 0.004s
? github.com/gtsteffaniak/filebrowser/share [no test files]
? github.com/gtsteffaniak/filebrowser/storage [no test files]
? github.com/gtsteffaniak/filebrowser/storage/bolt [no test files]
PASS
ok github.com/gtsteffaniak/filebrowser/users 0.003s
ok github.com/gtsteffaniak/filebrowser/users 0.004s
? github.com/gtsteffaniak/filebrowser/version [no test files]
FAIL

View File

@ -2,8 +2,10 @@ package main
import (
"github.com/gtsteffaniak/filebrowser/cmd"
"github.com/gtsteffaniak/filebrowser/settings"
)
func main() {
settings.Initialize()
cmd.StartFilebrowser()
}

View File

@ -1,25 +1,49 @@
package settings
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/goccy/go-yaml"
)
var GlobalConfiguration Settings
func init() {
func Initialize() {
// Open and read the YAML file
yamlFile, err := os.Open("filebrowser.yaml")
if err != nil {
log.Fatalf("Error opening YAML file: %v", err)
log.Println("Error opening config file: ", err)
log.Println("Using default config only")
// Get the current directory
dir, err := os.Getwd()
if err != nil {
fmt.Println("Error:", err)
return
}
// Use the filepath package to join the directory and file names
err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
fmt.Println("Error:", err)
return err
}
// Check if it's a regular file (not a directory)
if !info.IsDir() {
fmt.Println(path)
}
return nil
})
setDefaults()
return
}
defer yamlFile.Close()
stat, err := yamlFile.Stat()
if err != nil {
log.Fatalf("Error getting file information: %v", err)
log.Fatalf("Error getting file information: %s", err.Error())
}
yamlData := make([]byte, stat.Size())
@ -27,7 +51,6 @@ func init() {
if err != nil {
log.Fatalf("Error reading YAML data: %v", err)
}
setDefaults()
// Unmarshal the YAML data into the Settings struct
err = yaml.Unmarshal(yamlData, &GlobalConfiguration)
if err != nil {

View File

@ -0,0 +1,10 @@
package settings
import (
"testing"
)
func TestConfigLoad(t *testing.T) {
Initialize()
t.Log("Say bye")
}