diff --git a/bolt/share.go b/bolt/share.go index cbe6eed5..07ab628a 100644 --- a/bolt/share.go +++ b/bolt/share.go @@ -13,24 +13,24 @@ type ShareStore struct { // Get gets a Share Link from an hash. func (s ShareStore) Get(hash string) (*fm.ShareLink, error) { - var v *fm.ShareLink + var v fm.ShareLink err := s.DB.One("Hash", hash, &v) if err == storm.ErrNotFound { - return v, fm.ErrNotExist + return nil, fm.ErrNotExist } - return v, err + return &v, err } // GetPermanent gets the permanent link from a path. func (s ShareStore) GetPermanent(path string) (*fm.ShareLink, error) { - var v *fm.ShareLink + var v fm.ShareLink err := s.DB.Select(q.Eq("Path", path), q.Eq("Expires", false)).First(&v) if err == storm.ErrNotFound { - return v, fm.ErrNotExist + return nil, fm.ErrNotExist } - return v, err + return &v, err } // GetByPath gets all the links for a specific path. @@ -48,6 +48,10 @@ func (s ShareStore) GetByPath(hash string) ([]*fm.ShareLink, error) { func (s ShareStore) Gets() ([]*fm.ShareLink, error) { var v []*fm.ShareLink err := s.DB.All(&v) + if err == storm.ErrNotFound { + return v, fm.ErrNotExist + } + return v, err } diff --git a/caddy/parser/parser.go b/caddy/parser/parser.go index 664cb4a6..cf06e9fd 100644 --- a/caddy/parser/parser.go +++ b/caddy/parser/parser.go @@ -17,7 +17,6 @@ import ( "github.com/hacdias/fileutils" "github.com/mholt/caddy" "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/spf13/viper" ) var databases = map[string]*storm.DB{} @@ -205,7 +204,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro } m := &filemanager.FileManager{ - NoAuth: viper.GetBool("NoAuth"), + NoAuth: noAuth, BaseURL: "", PrefixURL: "", DefaultUser: u, diff --git a/http/http.go b/http/http.go index 7684a79e..10040890 100644 --- a/http/http.go +++ b/http/http.go @@ -9,7 +9,6 @@ import ( "strings" "time" - "github.com/asdine/storm" fm "github.com/hacdias/filemanager" ) @@ -242,7 +241,7 @@ func renderFile(c *fm.Context, w http.ResponseWriter, file string, contentType s // sharePage build the share page. func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) { s, err := c.Store.Share.Get(r.URL.Path) - if err == storm.ErrNotFound { + if err == fm.ErrNotExist { return renderFile( c, w, c.Assets.MustString("static/share/404.html"), diff --git a/http/share.go b/http/share.go index d8321b95..ba2035c2 100644 --- a/http/share.go +++ b/http/share.go @@ -8,7 +8,6 @@ import ( "strings" "time" - "github.com/asdine/storm" fm "github.com/hacdias/filemanager" ) @@ -30,7 +29,7 @@ func shareHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, e func shareGetHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) { path := filepath.Join(c.User.Scope, r.URL.Path) s, err := c.Store.Share.GetByPath(path) - if err == storm.ErrNotFound { + if err == fm.ErrNotExist { return http.StatusNotFound, nil } @@ -107,7 +106,7 @@ func sharePostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in func shareDeleteHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) { s, err := c.Store.Share.Get(strings.TrimPrefix(r.URL.Path, "/")) - if err == storm.ErrNotFound { + if err == fm.ErrNotExist { return http.StatusNotFound, nil }