From df90311453e7f57bbd70be83f91c2849de37425b Mon Sep 17 00:00:00 2001 From: Xhofe Date: Fri, 1 Apr 2022 20:40:57 +0800 Subject: [PATCH 1/2] fix(webdav): alist path not found --- server/common/common.go | 8 ++++---- server/webdav/file.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/common/common.go b/server/common/common.go index cbebf57c605..34028d5603c 100644 --- a/server/common/common.go +++ b/server/common/common.go @@ -38,10 +38,10 @@ func ParsePath(rawPath string) (*model.Account, string, base.Driver, error) { if bIndex != -1 { name = name[:bIndex] } - if name == "/" { - name = "" - } - return &account, strings.TrimPrefix(rawPath, name), driver, nil + //if name == "/" { + // name = "" + //} + return &account, utils.ParsePath(strings.TrimPrefix(rawPath, name)), driver, nil } func ErrorResp(c *gin.Context, err error, code int) { diff --git a/server/webdav/file.go b/server/webdav/file.go index 5a61d4217b1..aee27556067 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -42,6 +42,7 @@ func (fs *FileSystem) File(rawPath string) (*model.File, error) { }, nil } account, path_, driver, err := common.ParsePath(rawPath) + log.Debugln(account, path_, driver, err) if err != nil { return nil, err } From 0537449335eb5b0f83cae5cbce128fc8c3416428 Mon Sep 17 00:00:00 2001 From: Xhofe Date: Fri, 1 Apr 2022 21:57:55 +0800 Subject: [PATCH 2/2] fix(webdav): virtual path no account --- server/webdav/file.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/server/webdav/file.go b/server/webdav/file.go index aee27556067..0dfa67cd55a 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -31,19 +31,21 @@ func (fs *FileSystem) File(rawPath string) (*model.File, error) { if f, ok := upFileMap[rawPath]; ok { return f, nil } - if model.AccountsCount() > 1 && rawPath == "/" { - now := time.Now() - return &model.File{ - Name: "root", - Size: 0, - Type: conf.FOLDER, - Driver: "root", - UpdatedAt: &now, - }, nil - } account, path_, driver, err := common.ParsePath(rawPath) log.Debugln(account, path_, driver, err) if err != nil { + if err.Error() == "path not found" { + accountFiles := model.GetAccountFilesByPath(rawPath) + if len(accountFiles) != 0 { + now := time.Now() + return &model.File{ + Name: "root", + Size: 0, + Type: conf.FOLDER, + UpdatedAt: &now, + }, nil + } + } return nil, err } return operate.File(driver, account, path_)