From 377048fd35b08aa4640d8fe97882e25b659cd28e Mon Sep 17 00:00:00 2001 From: Mickael KERJEAN Date: Mon, 26 Nov 2018 22:58:10 +1100 Subject: [PATCH] fix (share): broken share feature --- server/ctrl/files.go | 3 +-- server/ctrl/share.go | 5 ++++- server/middleware/http.go | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/ctrl/files.go b/server/ctrl/files.go index 21961afa..4ea2c3f8 100644 --- a/server/ctrl/files.go +++ b/server/ctrl/files.go @@ -27,7 +27,6 @@ func FileLs(ctx App, res http.ResponseWriter, req *http.Request) { SendSuccessResults(res, files) return } - path, err := pathBuilder(ctx, req.URL.Query().Get("path")) if err != nil { SendErrorResult(res, err) @@ -57,7 +56,7 @@ func FileLs(ctx App, res http.ResponseWriter, req *http.Request) { files = append(files, f) } - var perms Metadata = Metadata{} + var perms Metadata = Metadata{} if obj, ok := ctx.Backend.(interface{ Meta(path string) Metadata }); ok { perms = obj.Meta(path) } diff --git a/server/ctrl/share.go b/server/ctrl/share.go index bb3f66be..cd1b4ce0 100644 --- a/server/ctrl/share.go +++ b/server/ctrl/share.go @@ -52,6 +52,7 @@ func ShareUpsert(ctx App, res http.ResponseWriter, req *http.Request) { return } backend_id = ctx.Share.Backend + auth_cookie = ctx.Share.Auth path_from = ctx.Share.Path } else { @@ -63,6 +64,9 @@ func ShareUpsert(ctx App, res http.ResponseWriter, req *http.Request) { } return a.Value }() + if ctx.Session["path"] != "" { + path_from = ctx.Session["path"] + } } if ctx.Share.Id != "" { @@ -201,7 +205,6 @@ func ShareVerifyProof(ctx App, res http.ResponseWriter, req *http.Request) { return } - Log.Info("SHAREGET('%+v')", s) SendSuccessResult(res, struct { Id string `json:"id"` Path string `json:"path"` diff --git a/server/middleware/http.go b/server/middleware/http.go index fca4b16f..70296a7a 100644 --- a/server/middleware/http.go +++ b/server/middleware/http.go @@ -23,15 +23,15 @@ func APIHandler(fn func(App, http.ResponseWriter, *http.Request), ctx App) http. } share_id := req.URL.Query().Get("share"); if ctx.Share, err = ExtractShare(req, &ctx, share_id); err != nil { - SendErrorResult(res, ErrNotValid) + SendErrorResult(res, err) return } if ctx.Session, err = ExtractSession(req, &ctx); err != nil { - SendErrorResult(res, ErrNotValid) + SendErrorResult(res, err) return } if ctx.Backend, err = ExtractBackend(req, &ctx); err != nil { - SendErrorResult(res, ErrNotValid) + SendErrorResult(res, err) return } resw := ResponseWriter{ResponseWriter: res} @@ -90,7 +90,7 @@ func ExtractShare(req *http.Request, ctx *App, share_id string) (Share, error) { return Share{}, nil } - if ctx.Config.Get("share.enable").Bool() == false { + if ctx.Config.Get("features.share.enable").Bool() == false { return Share{}, NewError("Feature isn't enable, contact your administrator", 405) }