From 3041da35ab555b3bfd63ba60135ae81f4c07961a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Sun, 28 Nov 2021 16:05:41 +0800 Subject: [PATCH] :bug: fix webdav proxy link auth --- server/webdav/file.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/server/webdav/file.go b/server/webdav/file.go index 1661570c..3b304893 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -80,6 +80,27 @@ func (fs *FileSystem) Files(rawPath string) ([]model.File, error) { return driver.Files(path_, account) } +func GetPW(path string) string { + if !conf.CheckDown { + return "" + } + meta, err := model.GetMetaByPath(path) + if err == nil { + if meta.Password != "" { + utils.Get16MD5Encode(meta.Password) + } + return "" + } else { + if !conf.CheckParent { + return "" + } + if path == "/" || path == "\\" { + return "" + } + return GetPW(filepath.Dir(path)) + } +} + func (fs *FileSystem) Link(host, rawPath string) (string, error) { rawPath = utils.ParsePath(rawPath) if model.AccountsCount() > 1 && rawPath == "/" { @@ -90,9 +111,10 @@ func (fs *FileSystem) Link(host, rawPath string) (string, error) { return "", err } if account.Type == "Native" || account.Type == "GoogleDrive" { - link := fmt.Sprintf("//%s/d%s", host, rawPath) + link := fmt.Sprintf("//%s/p%s", host, rawPath) if conf.CheckDown { - // TODO + pw := GetPW(filepath.Dir(rawPath)) + link += "?pw" + pw } log.Debugf("proxy link: %s", link) return link, nil