summaryrefslogtreecommitdiffstats
path: root/models/repo_generate.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-16 13:17:55 +0800
committerGitHub <noreply@github.com>2019-12-16 13:17:55 +0800
commit59d6401486627b8f47a0c6b62599e65a40f84c92 (patch)
tree8ec9f3a32e151cb3b1fba8c30caa60b71db78b7c /models/repo_generate.go
parent43ada6557135919b354d7384c4be699b539b10cb (diff)
downloadgitea-59d6401486627b8f47a0c6b62599e65a40f84c92.tar.gz
gitea-59d6401486627b8f47a0c6b62599e65a40f84c92.zip
Use ioutil.TmpDir for new created temp directory (#9368)
* Use os.TmpDir for new created temp directory * fix error message
Diffstat (limited to 'models/repo_generate.go')
-rw-r--r--models/repo_generate.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/models/repo_generate.go b/models/repo_generate.go
index 6dd8540d9e..98ef0ea000 100644
--- a/models/repo_generate.go
+++ b/models/repo_generate.go
@@ -179,10 +179,9 @@ func generateRepoCommit(e Engine, repo, templateRepo, generateRepo *Repository,
// generateRepository initializes repository from template
func generateRepository(e Engine, repo, templateRepo, generateRepo *Repository) (err error) {
- tmpDir := filepath.Join(os.TempDir(), "gitea-"+repo.Name+"-"+com.ToStr(time.Now().Nanosecond()))
-
- if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
- return fmt.Errorf("Failed to create dir %s: %v", tmpDir, err)
+ tmpDir, err := ioutil.TempDir(os.TempDir(), "gitea-"+repo.Name)
+ if err != nil {
+ return fmt.Errorf("Failed to create temp dir for repository %s: %v", repo.repoPath(e), err)
}
defer func() {