Skip to content

Commit

Permalink
fix additional slash in data path
Browse files Browse the repository at this point in the history
  • Loading branch information
vintikzzz committed Oct 5, 2024
1 parent cdca8b6 commit 2551800
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ server/server
client/client

.DS_Store
server/__debug_bin
server/__debug_bin
server/.env
10 changes: 4 additions & 6 deletions server/services/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func GetDir(location string, hash string) (string, error) {
if strings.HasSuffix(location, "*") {
prefix := strings.TrimSuffix(location, "*")
dir, lp := path.Split(prefix)
if dir == "" {
dir = "."
}

files, err := os.ReadDir(dir)
if err != nil {
return "", err
Expand All @@ -51,15 +49,15 @@ func GetDir(location string, hash string) (string, error) {
}
}
if len(dirs) == 0 {
return prefix + "/" + hash, nil
return prefix + string(os.PathSeparator) + hash, nil
} else if len(dirs) == 1 {
return dir + "/" + dirs[0] + "/" + hash, nil
return dir + dirs[0] + string(os.PathSeparator) + hash, nil
} else {
d, err := DistributeByHash(dirs, hash)
if err != nil {
return "", err
}
return dir + "/" + d + "/" + hash, nil
return dir + d + string(os.PathSeparator) + hash, nil
}
} else {
return location + "/" + hash, nil
Expand Down

0 comments on commit 2551800

Please sign in to comment.