mirror of
https://github.com/HChaZZY/alist.git
synced 2025-12-06 11:03:49 +08:00
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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ v2 ]
|
branches: [ v2 ]
|
||||||
pull_request:
|
|
||||||
branches: [ v2 ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_docker:
|
build_docker:
|
||||||
|
|||||||
@@ -207,6 +207,9 @@ func GetAccountsByPath(path string) []Account {
|
|||||||
if bIndex != -1 {
|
if bIndex != -1 {
|
||||||
name = name[:bIndex]
|
name = name[:bIndex]
|
||||||
}
|
}
|
||||||
|
if name == "/" {
|
||||||
|
name = ""
|
||||||
|
}
|
||||||
// 不是这个账号
|
// 不是这个账号
|
||||||
if path != name && !strings.HasPrefix(path, name+"/") {
|
if path != name && !strings.HasPrefix(path, name+"/") {
|
||||||
continue
|
continue
|
||||||
@@ -253,6 +256,9 @@ func GetAccountFilesByPath(prefix string) []File {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
full := utils.ParsePath(v.Name)
|
full := utils.ParsePath(v.Name)
|
||||||
|
if len(full) <= len(prefix) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// 不是以prefix为前缀
|
// 不是以prefix为前缀
|
||||||
if !strings.HasPrefix(full, prefix+"/") && prefix != "/" {
|
if !strings.HasPrefix(full, prefix+"/") && prefix != "/" {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ func ParsePath(rawPath string) (*model.Account, string, base.Driver, error) {
|
|||||||
if bIndex != -1 {
|
if bIndex != -1 {
|
||||||
name = name[:bIndex]
|
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) {
|
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 {
|
if f, ok := upFileMap[rawPath]; ok {
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
if model.AccountsCount() > 1 && rawPath == "/" {
|
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()
|
now := time.Now()
|
||||||
return &model.File{
|
return &model.File{
|
||||||
Name: "root",
|
Name: "root",
|
||||||
Size: 0,
|
Size: 0,
|
||||||
Type: conf.FOLDER,
|
Type: conf.FOLDER,
|
||||||
Driver: "root",
|
|
||||||
UpdatedAt: &now,
|
UpdatedAt: &now,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
account, path_, driver, err := common.ParsePath(rawPath)
|
}
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return operate.File(driver, account, path_)
|
return operate.File(driver, account, path_)
|
||||||
|
|||||||
Reference in New Issue
Block a user