🧹: gofmt

Former-commit-id: 9548d370497e13d436abbc670cf40d360badab9f [formerly f29ba9c4dcf9962c3a5045629526296cd2b43ad8] [formerly 3f89c094c1b3330c8d6f1b2379d6309567d12210 [formerly 92fda0070c]]
Former-commit-id: 4ad64211019e0236f0eaa6e041a8793e899954fe [formerly 6bf71ffba205b563ff6cd0c7487d9a328c757686]
Former-commit-id: 4c7afe072fc3e2a225ca5a7dbf3f3beb66b44058
pull/726/head
Henrique Dias 2019-01-05 23:01:16 +00:00
parent 12b2c21522
commit ea434ffc04
12 changed files with 22 additions and 23 deletions

View File

@ -4,9 +4,9 @@ import (
"net/http" "net/http"
"os" "os"
"github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/settings" "github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/users" "github.com/filebrowser/filebrowser/v2/users"
"github.com/filebrowser/filebrowser/v2/errors"
) )
// MethodProxyAuth is used to identify no auth. // MethodProxyAuth is used to identify no auth.

View File

@ -16,10 +16,10 @@ func init() {
var importCmd = &cobra.Command{ var importCmd = &cobra.Command{
Use: "import", Use: "import",
Short: "Imports an old configuration", 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 import share links because they are incompatible with
this version.`, this version.`,
Args: cobra.NoArgs, Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
oldDB := mustGetString(cmd, "old.database") oldDB := mustGetString(cmd, "old.database")
oldConf := mustGetString(cmd, "old.config") oldConf := mustGetString(cmd, "old.config")

View File

@ -20,12 +20,12 @@ func init() {
var rulesCmd = &cobra.Command{ var rulesCmd = &cobra.Command{
Use: "rules", Use: "rules",
Short: "Rules management utility", 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 "username" and "id". You must either set only one of them
or none. If you set one of them, the command will apply to 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 an user, otherwise it will be applied to the global set or
rules.`, rules.`,
Args: cobra.NoArgs, Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
cmd.Help() cmd.Help()
os.Exit(0) os.Exit(0)

View File

@ -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("/raw").Handler(handle(rawHandler, "/api/raw", storage)).Methods("GET")
api.PathPrefix("/command").Handler(handle(commandsHandler, "/api/command", 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") api.PathPrefix("/search").Handler(handle(searchHandler, "/api/search", storage)).Methods("GET")
public := api.PathPrefix("/public").Subrouter() public := api.PathPrefix("/public").Subrouter()
public.PathPrefix("/dl").Handler(handle(publicDlHandler, "/api/public/dl/", storage)).Methods("GET") public.PathPrefix("/dl").Handler(handle(publicDlHandler, "/api/public/dl/", storage)).Methods("GET")
public.PathPrefix("/share").Handler(handle(publicShareHandler, "/api/public/share/", storage)).Methods("GET") public.PathPrefix("/share").Handler(handle(publicShareHandler, "/api/public/share/", storage)).Methods("GET")

View File

@ -17,10 +17,10 @@ import (
var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
file, err := files.NewFileInfo(files.FileOptions{ file, err := files.NewFileInfo(files.FileOptions{
Fs: d.user.Fs, Fs: d.user.Fs,
Path: r.URL.Path, Path: r.URL.Path,
Modify: d.user.Perm.Modify, Modify: d.user.Perm.Modify,
Expand: true, Expand: true,
Checker: d, Checker: d,
}) })
if err != nil { if err != nil {

View File

@ -2,12 +2,12 @@ package http
import ( import (
"encoding/json" "encoding/json"
"text/template"
"log" "log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"text/template"
"github.com/GeertJohan/go.rice" "github.com/GeertJohan/go.rice"
"github.com/filebrowser/filebrowser/v2/auth" "github.com/filebrowser/filebrowser/v2/auth"

View File

@ -1,4 +1,3 @@
//go:generate cd http && rice embed-go
package main package main
import ( import (

View File

@ -3,8 +3,8 @@ package runner
import ( import (
"os/exec" "os/exec"
"github.com/mholt/caddy"
"github.com/filebrowser/filebrowser/v2/settings" "github.com/filebrowser/filebrowser/v2/settings"
"github.com/mholt/caddy"
) )
// ParseCommand parses the command taking in account if the current // ParseCommand parses the command taking in account if the current

View File

@ -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 { return afero.Walk(fs, scope, func(path string, f os.FileInfo, err error) error {
path = strings.TrimPrefix(path, "/") path = strings.TrimPrefix(path, "/")
path = strings.Replace(path, "\\", "/", -1) path = strings.Replace(path, "\\", "/", -1)
if !checker.Check(path) { if !checker.Check(path) {
return nil return nil
} }

View File

@ -1,9 +1,9 @@
package bolt package bolt
import ( import (
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/asdine/storm" "github.com/asdine/storm"
"github.com/filebrowser/filebrowser/v2/auth" "github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/share" "github.com/filebrowser/filebrowser/v2/share"
"github.com/filebrowser/filebrowser/v2/storage" "github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/users" "github.com/filebrowser/filebrowser/v2/users"
@ -13,13 +13,13 @@ import (
func NewStorage(db *storm.DB) *storage.Storage { func NewStorage(db *storm.DB) *storage.Storage {
users := users.NewStorage(usersBackend{db: db}) users := users.NewStorage(usersBackend{db: db})
share := share.NewStorage(shareBackend{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) auth := auth.NewStorage(authBackend{db: db}, users)
return &storage.Storage{ return &storage.Storage{
Auth: auth, Auth: auth,
Users: users, Users: users,
Share: share, Share: share,
Settings: settings, Settings: settings,
} }
} }

View File

@ -27,7 +27,7 @@ func (s shareBackend) GetPermanent(path string, id uint) (*share.Link, error) {
if err == storm.ErrNotFound { if err == storm.ErrNotFound {
return nil, errors.ErrNotExist return nil, errors.ErrNotExist
} }
return &v, err return &v, err
} }

View File

@ -10,8 +10,8 @@ import (
// Storage is a storage powered by a Backend whih makes the neccessary // Storage is a storage powered by a Backend whih makes the neccessary
// verifications when fetching and saving data to ensure consistency. // verifications when fetching and saving data to ensure consistency.
type Storage struct { type Storage struct {
Users *users.Storage Users *users.Storage
Share *share.Storage Share *share.Storage
Auth *auth.Storage Auth *auth.Storage
Settings *settings.Storage Settings *settings.Storage
} }