diff --git a/.gitignore b/.gitignore index 4a76d8c..5503a29 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ server/server client/client .DS_Store -server/__debug_bin \ No newline at end of file +server/__debug_bin +server/.env \ No newline at end of file diff --git a/server/services/common.go b/server/services/common.go index 12367d3..32cd34c 100644 --- a/server/services/common.go +++ b/server/services/common.go @@ -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 @@ -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