Merge pull request #727 from alexandrestein/weakClientFileName
Update download names file for weak clientspull/729/head
commit
b87ba12a7d
2
frontend
2
frontend
|
@ -1 +1 @@
|
||||||
Subproject commit 633579e7380a47158dd71c8de3d52dcaca8ad014
|
Subproject commit ed5f51c3ff0e3f479d8c076f00a8fa764d6109fb
|
|
@ -2,6 +2,7 @@ package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/filebrowser/filebrowser/v2/files"
|
"github.com/filebrowser/filebrowser/v2/files"
|
||||||
)
|
)
|
||||||
|
@ -9,9 +10,12 @@ import (
|
||||||
var withHashFile = func(fn handleFunc) handleFunc {
|
var withHashFile = func(fn handleFunc) handleFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
link, err := d.store.Share.GetByHash(r.URL.Path)
|
link, err := d.store.Share.GetByHash(r.URL.Path)
|
||||||
|
if err != nil {
|
||||||
|
link, err = d.store.Share.GetByHash(ifPathWithName(r))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errToStatus(err), err
|
return errToStatus(err), err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
user, err := d.store.Users.Get(d.server.Root, link.UserID)
|
user, err := d.store.Users.Get(d.server.Root, link.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -36,6 +40,12 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ifPathWithName(r *http.Request) string {
|
||||||
|
pathElements := strings.Split(r.URL.Path, "/")
|
||||||
|
id := pathElements[len(pathElements)-2]
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
return renderJSON(w, r, d.raw)
|
return renderJSON(w, r, d.raw)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue