mirror of
https://github.com/filebrowser/filebrowser.git
synced 2026-01-23 02:35:10 +00:00
refactor: cleanup package names (#5605)
This commit is contained in:
parent
a6934e40ff
commit
f029c3005e
33 changed files with 78 additions and 78 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/golang-jwt/jwt/v5/request"
|
||||
|
||||
fbAuth "github.com/filebrowser/filebrowser/v2/auth"
|
||||
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
|
@ -185,7 +185,7 @@ var signupHandler = func(_ http.ResponseWriter, r *http.Request, d *data) (int,
|
|||
log.Printf("new user: %s, home dir: [%s].", user.Username, userHome)
|
||||
|
||||
err = d.store.Users.Save(user)
|
||||
if errors.Is(err, fbErrors.ErrExist) {
|
||||
if errors.Is(err, fberrors.ErrExist) {
|
||||
return http.StatusConflict, err
|
||||
} else if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//go:build !dev
|
||||
|
||||
package http
|
||||
package fbhttp
|
||||
|
||||
// global headers to append to every response
|
||||
var globalHeaders = map[string]string{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//go:generate go-enum --sql --marshal --names --file $GOFILE
|
||||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by go-enum
|
||||
// DO NOT EDIT!
|
||||
|
||||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/shirou/gopsutil/v4/disk"
|
||||
"github.com/spf13/afero"
|
||||
|
||||
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
"github.com/filebrowser/filebrowser/v2/files"
|
||||
"github.com/filebrowser/filebrowser/v2/fileutils"
|
||||
)
|
||||
|
|
@ -44,7 +44,7 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
|||
|
||||
if checksum := r.URL.Query().Get("checksum"); checksum != "" {
|
||||
err := file.Checksum(checksum)
|
||||
if errors.Is(err, fbErrors.ErrInvalidOption) {
|
||||
if errors.Is(err, fberrors.ErrInvalidOption) {
|
||||
return http.StatusBadRequest, nil
|
||||
} else if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
|
|
@ -238,7 +238,7 @@ func checkParent(src, dst string) error {
|
|||
|
||||
rel = filepath.ToSlash(rel)
|
||||
if !strings.HasPrefix(rel, "../") && rel != ".." && rel != "." {
|
||||
return fbErrors.ErrSourceIsParent
|
||||
return fberrors.ErrSourceIsParent
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -304,13 +304,13 @@ func patchAction(ctx context.Context, action, src, dst string, d *data, fileCach
|
|||
switch action {
|
||||
case "copy":
|
||||
if !d.user.Perm.Create {
|
||||
return fbErrors.ErrPermissionDenied
|
||||
return fberrors.ErrPermissionDenied
|
||||
}
|
||||
|
||||
return fileutils.Copy(d.user.Fs, src, dst, d.settings.FileMode, d.settings.DirMode)
|
||||
case "rename":
|
||||
if !d.user.Perm.Rename {
|
||||
return fbErrors.ErrPermissionDenied
|
||||
return fberrors.ErrPermissionDenied
|
||||
}
|
||||
src = path.Clean("/" + src)
|
||||
dst = path.Clean("/" + dst)
|
||||
|
|
@ -335,7 +335,7 @@ func patchAction(ctx context.Context, action, src, dst string, d *data, fileCach
|
|||
|
||||
return fileutils.MoveFile(d.user.Fs, src, dst, d.settings.FileMode, d.settings.DirMode)
|
||||
default:
|
||||
return fmt.Errorf("unsupported action %s: %w", action, fbErrors.ErrInvalidRequestParams)
|
||||
return fmt.Errorf("unsupported action %s: %w", action, fberrors.ErrInvalidRequestParams)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
"github.com/filebrowser/filebrowser/v2/share"
|
||||
)
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ var shareListHandler = withPermShare(func(w http.ResponseWriter, r *http.Request
|
|||
} else {
|
||||
s, err = d.store.Share.FindByUserID(d.user.ID)
|
||||
}
|
||||
if errors.Is(err, fbErrors.ErrNotExist) {
|
||||
if errors.Is(err, fberrors.ErrNotExist) {
|
||||
return renderJSON(w, r, []*share.Link{})
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ var shareListHandler = withPermShare(func(w http.ResponseWriter, r *http.Request
|
|||
|
||||
var shareGetsHandler = withPermShare(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
s, err := d.store.Share.Gets(r.URL.Path, d.user.ID)
|
||||
if errors.Is(err, fbErrors.ErrNotExist) {
|
||||
if errors.Is(err, fberrors.ErrNotExist) {
|
||||
return renderJSON(w, r, []*share.Link{})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ func getUserID(r *http.Request) (uint, error) {
|
|||
|
||||
func getUser(_ http.ResponseWriter, r *http.Request) (*modifyUserRequest, error) {
|
||||
if r.Body == nil {
|
||||
return nil, fbErrors.ErrEmptyRequest
|
||||
return nil, fberrors.ErrEmptyRequest
|
||||
}
|
||||
|
||||
req := &modifyUserRequest{}
|
||||
|
|
@ -46,7 +46,7 @@ func getUser(_ http.ResponseWriter, r *http.Request) (*modifyUserRequest, error)
|
|||
}
|
||||
|
||||
if req.What != "user" {
|
||||
return nil, fbErrors.ErrInvalidDataType
|
||||
return nil, fberrors.ErrInvalidDataType
|
||||
}
|
||||
|
||||
return req, nil
|
||||
|
|
@ -87,7 +87,7 @@ var usersGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *
|
|||
|
||||
var userGetHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
u, err := d.store.Users.Get(d.server.Root, d.raw.(uint))
|
||||
if errors.Is(err, fbErrors.ErrNotExist) {
|
||||
if errors.Is(err, fberrors.ErrNotExist) {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ var userPostHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *
|
|||
}
|
||||
|
||||
if req.Data.Password == "" {
|
||||
return http.StatusBadRequest, fbErrors.ErrEmptyPassword
|
||||
return http.StatusBadRequest, fberrors.ErrEmptyPassword
|
||||
}
|
||||
|
||||
req.Data.Password, err = users.ValidateAndHashPwd(req.Data.Password, d.settings.MinimumPasswordLength)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package http
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue