Ensure tmp dir is created before creating temp file (#5977)

This commit is contained in:
WithoutPants
2025-06-30 07:52:32 +10:00
committed by GitHub
parent bd8ec8cb83
commit 7215b6e918

View File

@@ -43,6 +43,9 @@ func (gp *generatedPaths) GetTmpPath(fileName string) string {
// TempFile creates a temporary file using os.CreateTemp. // TempFile creates a temporary file using os.CreateTemp.
// It is the equivalent of calling os.CreateTemp using Tmp and pattern. // It is the equivalent of calling os.CreateTemp using Tmp and pattern.
func (gp *generatedPaths) TempFile(pattern string) (*os.File, error) { func (gp *generatedPaths) TempFile(pattern string) (*os.File, error) {
if err := gp.EnsureTmpDir(); err != nil {
logger.Warnf("Could not ensure existence of a temporary directory: %v", err)
}
return os.CreateTemp(gp.Tmp, pattern) return os.CreateTemp(gp.Tmp, pattern)
} }