From ea434ffc04e186842611d0b6029ef69bcf7542d2 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 5 Jan 2019 23:01:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9:=20gofmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 9548d370497e13d436abbc670cf40d360badab9f [formerly f29ba9c4dcf9962c3a5045629526296cd2b43ad8] [formerly 3f89c094c1b3330c8d6f1b2379d6309567d12210 [formerly 92fda0070cb61c3739fdfe340b65a39fd73eda8b]] Former-commit-id: 4ad64211019e0236f0eaa6e041a8793e899954fe [formerly 6bf71ffba205b563ff6cd0c7487d9a328c757686] Former-commit-id: 4c7afe072fc3e2a225ca5a7dbf3f3beb66b44058 --- auth/proxy.go | 2 +- cmd/import.go | 4 ++-- cmd/rules.go | 4 ++-- http/http.go | 2 +- http/resource.go | 8 ++++---- http/static.go | 2 +- main.go | 1 - runner/parser.go | 2 +- search/search.go | 2 +- storage/bolt/bolt.go | 10 +++++----- storage/bolt/share.go | 2 +- storage/storage.go | 6 +++--- 12 files changed, 22 insertions(+), 23 deletions(-) diff --git a/auth/proxy.go b/auth/proxy.go index ff0e062af..f23b70fb0 100644 --- a/auth/proxy.go +++ b/auth/proxy.go @@ -4,9 +4,9 @@ import ( "net/http" "os" + "github.com/filebrowser/filebrowser/v2/errors" "github.com/filebrowser/filebrowser/v2/settings" "github.com/filebrowser/filebrowser/v2/users" - "github.com/filebrowser/filebrowser/v2/errors" ) // MethodProxyAuth is used to identify no auth. diff --git a/cmd/import.go b/cmd/import.go index b90b34498..2dd495cd2 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -16,10 +16,10 @@ func init() { var importCmd = &cobra.Command{ Use: "import", Short: "Imports an old configuration", - Long: `Imports an old configuration. This command DOES NOT + Long: `Imports an old configuration. This command DOES NOT import share links because they are incompatible with this version.`, - Args: cobra.NoArgs, + Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { oldDB := mustGetString(cmd, "old.database") oldConf := mustGetString(cmd, "old.config") diff --git a/cmd/rules.go b/cmd/rules.go index 473a85721..99f20814c 100644 --- a/cmd/rules.go +++ b/cmd/rules.go @@ -20,12 +20,12 @@ func init() { var rulesCmd = &cobra.Command{ Use: "rules", Short: "Rules management utility", - Long: `On each subcommand you'll have available at least two flags: + Long: `On each subcommand you'll have available at least two flags: "username" and "id". You must either set only one of them or none. If you set one of them, the command will apply to an user, otherwise it will be applied to the global set or rules.`, - Args: cobra.NoArgs, + Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { cmd.Help() os.Exit(0) diff --git a/http/http.go b/http/http.go index 7978805c7..8333cf622 100644 --- a/http/http.go +++ b/http/http.go @@ -49,7 +49,7 @@ func NewHandler(storage *storage.Storage) (http.Handler, error) { api.PathPrefix("/raw").Handler(handle(rawHandler, "/api/raw", storage)).Methods("GET") api.PathPrefix("/command").Handler(handle(commandsHandler, "/api/command", storage)).Methods("GET") api.PathPrefix("/search").Handler(handle(searchHandler, "/api/search", storage)).Methods("GET") - + public := api.PathPrefix("/public").Subrouter() public.PathPrefix("/dl").Handler(handle(publicDlHandler, "/api/public/dl/", storage)).Methods("GET") public.PathPrefix("/share").Handler(handle(publicShareHandler, "/api/public/share/", storage)).Methods("GET") diff --git a/http/resource.go b/http/resource.go index 99135d494..6defa0073 100644 --- a/http/resource.go +++ b/http/resource.go @@ -17,10 +17,10 @@ import ( var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { file, err := files.NewFileInfo(files.FileOptions{ - Fs: d.user.Fs, - Path: r.URL.Path, - Modify: d.user.Perm.Modify, - Expand: true, + Fs: d.user.Fs, + Path: r.URL.Path, + Modify: d.user.Perm.Modify, + Expand: true, Checker: d, }) if err != nil { diff --git a/http/static.go b/http/static.go index 0ee8a1702..6e84be850 100644 --- a/http/static.go +++ b/http/static.go @@ -2,12 +2,12 @@ package http import ( "encoding/json" - "text/template" "log" "net/http" "os" "path/filepath" "strings" + "text/template" "github.com/GeertJohan/go.rice" "github.com/filebrowser/filebrowser/v2/auth" diff --git a/main.go b/main.go index 1d562df3c..fa8b91361 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,3 @@ -//go:generate cd http && rice embed-go package main import ( diff --git a/runner/parser.go b/runner/parser.go index 0ff4f856f..83d44e660 100644 --- a/runner/parser.go +++ b/runner/parser.go @@ -3,8 +3,8 @@ package runner import ( "os/exec" - "github.com/mholt/caddy" "github.com/filebrowser/filebrowser/v2/settings" + "github.com/mholt/caddy" ) // ParseCommand parses the command taking in account if the current diff --git a/search/search.go b/search/search.go index ce85fa24f..68f1cb8bf 100644 --- a/search/search.go +++ b/search/search.go @@ -21,7 +21,7 @@ func Search(fs afero.Fs, scope, query string, checker rules.Checker, found func( return afero.Walk(fs, scope, func(path string, f os.FileInfo, err error) error { path = strings.TrimPrefix(path, "/") path = strings.Replace(path, "\\", "/", -1) - + if !checker.Check(path) { return nil } diff --git a/storage/bolt/bolt.go b/storage/bolt/bolt.go index be500823b..41e2e1916 100644 --- a/storage/bolt/bolt.go +++ b/storage/bolt/bolt.go @@ -1,9 +1,9 @@ package bolt import ( - "github.com/filebrowser/filebrowser/v2/settings" "github.com/asdine/storm" "github.com/filebrowser/filebrowser/v2/auth" + "github.com/filebrowser/filebrowser/v2/settings" "github.com/filebrowser/filebrowser/v2/share" "github.com/filebrowser/filebrowser/v2/storage" "github.com/filebrowser/filebrowser/v2/users" @@ -13,13 +13,13 @@ import ( func NewStorage(db *storm.DB) *storage.Storage { users := users.NewStorage(usersBackend{db: db}) share := share.NewStorage(shareBackend{db: db}) - settings := settings.NewStorage(settingsBackend{ db: db}) + settings := settings.NewStorage(settingsBackend{db: db}) auth := auth.NewStorage(authBackend{db: db}, users) return &storage.Storage{ - Auth: auth, - Users: users, - Share: share, + Auth: auth, + Users: users, + Share: share, Settings: settings, } } diff --git a/storage/bolt/share.go b/storage/bolt/share.go index 1e6420e10..99d533816 100644 --- a/storage/bolt/share.go +++ b/storage/bolt/share.go @@ -27,7 +27,7 @@ func (s shareBackend) GetPermanent(path string, id uint) (*share.Link, error) { if err == storm.ErrNotFound { return nil, errors.ErrNotExist } - + return &v, err } diff --git a/storage/storage.go b/storage/storage.go index 8f2226166..3db87a23a 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -10,8 +10,8 @@ import ( // Storage is a storage powered by a Backend whih makes the neccessary // verifications when fetching and saving data to ensure consistency. type Storage struct { - Users *users.Storage - Share *share.Storage - Auth *auth.Storage + Users *users.Storage + Share *share.Storage + Auth *auth.Storage Settings *settings.Storage }