From 0537449335eb5b0f83cae5cbce128fc8c3416428 Mon Sep 17 00:00:00 2001 From: Xhofe Date: Fri, 1 Apr 2022 21:57:55 +0800 Subject: [PATCH] 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 aee27556..0dfa67cd 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_)