Skip to content

Commit

Permalink
chore: Merge pull request #884 from Xhofe/dev
Browse files Browse the repository at this point in the history
fix: some issues of webdav due to virtual path
  • Loading branch information
xhofe authored Apr 1, 2022
2 parents 876579e + 0537449 commit 3427291
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions server/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
23 changes: 13 additions & 10 deletions server/webdav/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +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_)
Expand Down

0 comments on commit 3427291

Please sign in to comment.