Git designed for AI agents.
storage: join Praefect's relative paths with path, not filepath
Loris Salsi7af2cc0a04e4
diff --git a/internal/gitaly/storage/repository_path.go b/internal/gitaly/storage/repository_path.goindex 4448f45..ddb9dc8 100644--- a/internal/gitaly/storage/repository_path.go+++ b/internal/gitaly/storage/repository_path.go@@ -3,19 +3,23 @@ package storageimport ("crypto/sha256""fmt"- "path/filepath"+ "path""regexp""strconv""strings")+// The paths below are relative paths of repositories, which use slashes on every system: they are+// joined with path, not path/filepath. On Windows, filepath.Join would make the pool prefix+// `@cluster\pools`, and praefectPoolDirRegexp would not compile (`\p` starts a Unicode class), which+// panics when any program that imports this package starts, the clients included.var (// PraefectRootPathPrefix is the root directory for all git repositories.PraefectRootPathPrefix = "@cluster"// praefectPoolPathPrefix is the prefix directory where Praefect places object pools.- praefectPoolPathPrefix = filepath.Join(PraefectRootPathPrefix, "pools")+ praefectPoolPathPrefix = path.Join(PraefectRootPathPrefix, "pools")// praefectRepositoryPathPrefix is the prefix directory where Praefect places repositories.- praefectRepositoryPathPrefix = filepath.Join(PraefectRootPathPrefix, "repositories")+ praefectRepositoryPathPrefix = path.Join(PraefectRootPathPrefix, "repositories")// prafectPoolDirRegexp is used to validate object pool directory structure and name as generated by Praefect.praefectPoolDirRegexp = regexp.MustCompile(praefectPoolPathPrefix + `/[0-9a-f]{2}/[0-9a-f]{2}/[0-9]+$`)// railsPoolDirRegexp is used to validate object pool directory structure and name as generated by Rails.@@ -65,5 +69,5 @@ func deriveDiskPath(prefixDir string, repositoryID int64) string {// an error.hasher.Write([]byte(strconv.FormatInt(repositoryID, 10)))hash := hasher.Sum(nil)- return filepath.Join(prefixDir, fmt.Sprintf("%x/%x/%d", hash[0:1], hash[1:2], repositoryID))+ return path.Join(prefixDir, fmt.Sprintf("%x/%x/%d", hash[0:1], hash[1:2], repositoryID))}