mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
fix #51
This commit is contained in:
parent
b9cbf2a49f
commit
b7dc9f4ffc
@ -10,7 +10,6 @@ package filemanager
|
|||||||
import (
|
import (
|
||||||
e "errors"
|
e "errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hacdias/caddy-filemanager/assets"
|
"github.com/hacdias/caddy-filemanager/assets"
|
||||||
@ -84,18 +83,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
|
|||||||
|
|
||||||
// Preprocess the PUT request if it's the case
|
// Preprocess the PUT request if it's the case
|
||||||
if r.Method == http.MethodPut {
|
if r.Method == http.MethodPut {
|
||||||
var urlp *url.URL
|
if handlers.PreProccessPUT(w, r, c, user) != nil {
|
||||||
urlp, err = url.Parse(strings.Replace(r.URL.String(), c.WebDavURL, "", 1))
|
|
||||||
if err != nil {
|
|
||||||
return code, err
|
|
||||||
}
|
|
||||||
|
|
||||||
fi, code, err = file.GetInfo(urlp, c, user)
|
|
||||||
if err != nil {
|
|
||||||
return code, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if handlers.PreProccessPUT(w, r, c, user, fi) != nil {
|
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hacdias/caddy-filemanager/config"
|
"github.com/hacdias/caddy-filemanager/config"
|
||||||
"github.com/hacdias/caddy-filemanager/file"
|
|
||||||
"github.com/spf13/hugo/parser"
|
"github.com/spf13/hugo/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ func PreProccessPUT(
|
|||||||
r *http.Request,
|
r *http.Request,
|
||||||
c *config.Config,
|
c *config.Config,
|
||||||
u *config.User,
|
u *config.User,
|
||||||
i *file.Info,
|
|
||||||
) (err error) {
|
) (err error) {
|
||||||
var (
|
var (
|
||||||
data = map[string]interface{}{}
|
data = map[string]interface{}{}
|
||||||
@ -43,7 +41,7 @@ func PreProccessPUT(
|
|||||||
|
|
||||||
switch kind {
|
switch kind {
|
||||||
case "frontmatter-only":
|
case "frontmatter-only":
|
||||||
if file, err = ParseFrontMatterOnlyFile(data, i.FileInfo.Name()); err != nil {
|
if file, err = ParseFrontMatterOnlyFile(data, r.URL.Path); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "content-only":
|
case "content-only":
|
||||||
@ -51,7 +49,7 @@ func PreProccessPUT(
|
|||||||
mainContent = strings.TrimSpace(mainContent)
|
mainContent = strings.TrimSpace(mainContent)
|
||||||
file = []byte(mainContent)
|
file = []byte(mainContent)
|
||||||
case "complete":
|
case "complete":
|
||||||
if file, err = ParseCompleteFile(data, i.Name(), u.FrontMatter); err != nil {
|
if file, err = ParseCompleteFile(data, r.URL.Path, u.FrontMatter); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user