diff --git a/server/common/files.go b/server/common/files.go index cd22e980..a99ee8ea 100644 --- a/server/common/files.go +++ b/server/common/files.go @@ -9,9 +9,9 @@ import ( func Path(rawPath string) (*model.File, []model.File, *model.Account, base.Driver, string, error) { account, path, driver, err := ParsePath(rawPath) + accountFiles := model.GetAccountFilesByPath(rawPath) if err != nil { if err.Error() == "path not found" { - accountFiles := model.GetAccountFilesByPath(rawPath) if len(accountFiles) != 0 { return nil, accountFiles, nil, nil, path, nil } @@ -21,6 +21,11 @@ func Path(rawPath string) (*model.File, []model.File, *model.Account, base.Drive log.Debugln("use account: ", account.Name) file, files, err := operate.Path(driver, account, path) if err != nil { + if err.Error() == "path not found" { + if len(accountFiles) != 0 { + return nil, accountFiles, nil, nil, path, nil + } + } return nil, nil, nil, nil, "", err } if file != nil { diff --git a/server/webdav/file.go b/server/webdav/file.go index 0dfa67cd..4583d808 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -48,7 +48,20 @@ func (fs *FileSystem) File(rawPath string) (*model.File, error) { } return nil, err } - return operate.File(driver, account, path_) + file, err := operate.File(driver, account, path_) + if err != nil && 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 file, err } func (fs *FileSystem) Files(ctx context.Context, rawPath string) ([]model.File, error) {