1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 23:17:19 +00:00

Use filepath.Join instead of path.Join for file system file operations (#33978)

This commit is contained in:
Lunny Xiao
2025-03-24 14:50:28 -07:00
committed by GitHub
parent 82bc8b8ce6
commit 3fe449c21a
12 changed files with 23 additions and 56 deletions

View File

@@ -10,7 +10,7 @@ import (
"io"
"mime/multipart"
"os"
"path"
"path/filepath"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/log"
@@ -53,7 +53,7 @@ func init() {
// UploadLocalPath returns where uploads is stored in local file system based on given UUID.
func UploadLocalPath(uuid string) string {
return path.Join(setting.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
return filepath.Join(setting.Repository.Upload.TempPath, uuid[0:1], uuid[1:2], uuid)
}
// LocalPath returns where uploads are temporarily stored in local file system.
@@ -69,7 +69,7 @@ func NewUpload(ctx context.Context, name string, buf []byte, file multipart.File
}
localPath := upload.LocalPath()
if err = os.MkdirAll(path.Dir(localPath), os.ModePerm); err != nil {
if err = os.MkdirAll(filepath.Dir(localPath), os.ModePerm); err != nil {
return nil, fmt.Errorf("MkdirAll: %w", err)
}