This commit is contained in:
Graham Steffaniak 2023-09-01 21:03:45 -05:00
parent 91f4a299c4
commit 667786e487
5 changed files with 15 additions and 53 deletions

View File

@ -89,14 +89,10 @@ user created with the credentials from options "username" and "password".`,
if !d.hadDB {
quickSetup(cmd.Flags(), d)
}
workersCount := serverConfig.NumImageProcessors
log.Println(serverConfig)
if workersCount < 1 {
if serverConfig.NumImageProcessors < 1 {
log.Fatal("Image resize workers count could not be < 1")
}
imgSvc := img.New(workersCount)
imgSvc := img.New(serverConfig.NumImageProcessors)
var fileCache diskcache.Interface = diskcache.NewNoOp()
cacheDir := "/tmp"
if cacheDir != "" {
@ -105,16 +101,12 @@ user created with the credentials from options "username" and "password".`,
}
fileCache = diskcache.New(afero.NewOsFs(), cacheDir)
}
// initialize indexing and schedule indexing ever n minutes (default 5)
go search.InitializeIndex(serverConfig.IndexingInterval)
_, err := os.Stat(serverConfig.Root)
checkErr(err)
var listener net.Listener
address := serverConfig.Address + ":" + strconv.Itoa(serverConfig.Port)
switch {
case serverConfig.Socket != "":
listener, err = net.Listen("unix", serverConfig.Socket)
@ -135,17 +127,13 @@ user created with the credentials from options "username" and "password".`,
listener, err = net.Listen("tcp", address)
checkErr(err)
}
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)
go cleanupHandler(listener, sigc)
assetsFs := dirFS{Dir: http.Dir("frontend/dist")}
handler, err := fbhttp.NewHandler(imgSvc, fileCache, d.store, &serverConfig, assetsFs)
checkErr(err)
defer listener.Close()
log.Println("Listening on", listener.Addr().String())
//nolint: gosec
if err := http.Serve(listener, handler); err != nil {
@ -241,13 +229,12 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) {
Shell: nil,
Rules: nil,
}
var err error
if settings.GlobalConfiguration.Auth.Method == "noAuth" {
set.Auth.Method = "noAuth"
if settings.GlobalConfiguration.Auth.Method == "noauth" {
set.Auth.Method = "noauth"
err = d.store.Auth.Save(&auth.NoAuth{})
} else {
set.Auth.Method = "json"
set.Auth.Method = "password"
err = d.store.Auth.Save(&auth.JSONAuth{})
}
err = d.store.Settings.Save(set)

View File

@ -1,37 +1,12 @@
general:
key: []
signup: true
createUserDir: false
userHomeBasePath: ""
scope: ""
locale: ""
viewMode: ""
singleClick: false
hideDotfiles: true
dateFormat: false
defaultSortBy: ""
perm:
admin: true
execute: true
create: true
rename: true
modify: true
delete: true
share: true
download: true
shell: []
rules: []
server:
indexingInterval: 5
numImageProcessors: 1
numImageProcessors: 2
socket: ""
tlsKey: ""
tlsCert: ""
enableThumbnails: true
resizePreview: false
enableExec: false
typeDetectionByHeader: true
authHook: ""
port: 8080
baseURL: "/"
address: ""
@ -44,7 +19,7 @@ auth:
key: ""
secret: ""
header: ""
method: "noauth"
method: noauth
command: ""
signup: false
shell: ""

View File

@ -49,7 +49,6 @@ var settingsPutHandler = withAdmin(func(w http.ResponseWriter, r *http.Request,
d.settings.Frontend = req.Frontend
d.settings.Shell = req.Shell
d.settings.Commands = req.Commands
err = d.store.Settings.Save(d.settings)
return errToStatus(err), err
})

View File

@ -1,7 +1,6 @@
package settings
import (
"io/ioutil"
"log"
"os"
@ -18,7 +17,13 @@ func init() {
}
defer yamlFile.Close()
yamlData, err := ioutil.ReadAll(yamlFile)
stat, err := yamlFile.Stat()
if err != nil {
log.Fatalf("Error getting file information: %v", err)
}
yamlData := make([]byte, stat.Size())
_, err = yamlFile.Read(yamlData)
if err != nil {
log.Fatalf("Error reading YAML data: %v", err)
}
@ -39,7 +44,7 @@ func setDefaults() {
IndexingInterval: 5,
Port: 8080,
NumImageProcessors: 1,
BaseURL: "/files",
BaseURL: "",
},
Auth: Auth{
Method: "password",

View File

@ -1,8 +1,6 @@
package bolt
import (
"fmt"
"github.com/asdine/storm/v3"
"github.com/gtsteffaniak/filebrowser/auth"
"github.com/gtsteffaniak/filebrowser/errors"
@ -26,8 +24,6 @@ func (s authBackend) Get(t string) (auth.Auther, error) {
default:
return nil, errors.ErrInvalidAuthMethod
}
fmt.Println("auth.go", t)
return auther, get(s.db, "auther", auther)
}