Skip to content

Commit 99b975e

Browse files
authored
fix: check and create dir (#2357)
Signed-off-by: 张启航 <[email protected]>
1 parent 08857cb commit 99b975e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

builder/sources/git.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ func GetCodeSourceDir(RepositoryURL, branch, tenantID string, ServiceID string)
8282
h.Write([]byte(RepositoryURL + branch + ServiceID))
8383
bs := h.Sum(nil)
8484
bsStr := fmt.Sprintf("%x", bs)
85-
return path.Join(sourceDir, "build", tenantID, bsStr)
85+
targetDir := path.Join(sourceDir, "build", tenantID, bsStr)
86+
87+
// Check if directory exists, create if not
88+
if _, err := os.Stat(targetDir); os.IsNotExist(err) {
89+
if err := os.MkdirAll(targetDir, 0755); err != nil {
90+
logrus.Errorf("Failed to create source directory %s: %v", targetDir, err)
91+
}
92+
}
93+
94+
return targetDir
8695
}
8796

8897
// CheckFileExist CheckFileExist

0 commit comments

Comments
 (0)