Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
342729179d | |||
0537449335 | |||
df90311453 | |||
876579ea3b | |||
e83081380e | |||
9daeaf7562 |
2
.github/workflows/build_docker.yml
vendored
2
.github/workflows/build_docker.yml
vendored
@ -3,8 +3,6 @@ name: build_docker
|
||||
on:
|
||||
push:
|
||||
branches: [ v2 ]
|
||||
pull_request:
|
||||
branches: [ v2 ]
|
||||
|
||||
jobs:
|
||||
build_docker:
|
||||
|
@ -207,6 +207,9 @@ func GetAccountsByPath(path string) []Account {
|
||||
if bIndex != -1 {
|
||||
name = name[:bIndex]
|
||||
}
|
||||
if name == "/" {
|
||||
name = ""
|
||||
}
|
||||
// 不是这个账号
|
||||
if path != name && !strings.HasPrefix(path, name+"/") {
|
||||
continue
|
||||
@ -253,6 +256,9 @@ func GetAccountFilesByPath(prefix string) []File {
|
||||
continue
|
||||
}
|
||||
full := utils.ParsePath(v.Name)
|
||||
if len(full) <= len(prefix) {
|
||||
continue
|
||||
}
|
||||
// 不是以prefix为前缀
|
||||
if !strings.HasPrefix(full, prefix+"/") && prefix != "/" {
|
||||
continue
|
||||
|
@ -38,7 +38,10 @@ func ParsePath(rawPath string) (*model.Account, string, base.Driver, error) {
|
||||
if bIndex != -1 {
|
||||
name = name[:bIndex]
|
||||
}
|
||||
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) {
|
||||
|
@ -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_)
|
||||
|
Reference in New Issue
Block a user