@@ -6,15 +6,13 @@ package models
66
77import (
88 "fmt"
9+ "io/ioutil"
910 "os"
1011 "path"
1112 "path/filepath"
12- "time"
1313
1414 "code.gitea.io/gitea/modules/log"
1515 "code.gitea.io/gitea/modules/setting"
16-
17- "github.com/unknwon/com"
1816)
1917
2018// LocalCopyPath returns the local repository temporary copy path.
@@ -27,11 +25,15 @@ func LocalCopyPath() string {
2725
2826// CreateTemporaryPath creates a temporary path
2927func CreateTemporaryPath (prefix string ) (string , error ) {
30- timeStr := com .ToStr (time .Now ().Nanosecond ()) // SHOULD USE SOMETHING UNIQUE
31- basePath := path .Join (LocalCopyPath (), prefix + "-" + timeStr + ".git" )
32- if err := os .MkdirAll (filepath .Dir (basePath ), os .ModePerm ); err != nil {
33- log .Error ("Unable to create temporary directory: %s (%v)" , basePath , err )
34- return "" , fmt .Errorf ("Failed to create dir %s: %v" , basePath , err )
28+ if err := os .MkdirAll (LocalCopyPath (), os .ModePerm ); err != nil {
29+ log .Error ("Unable to create localcopypath directory: %s (%v)" , LocalCopyPath (), err )
30+ return "" , fmt .Errorf ("Failed to create localcopypath directory %s: %v" , LocalCopyPath (), err )
31+ }
32+ basePath , err := ioutil .TempDir (LocalCopyPath (), prefix + "-*.git" )
33+ if err != nil {
34+ log .Error ("Unable to create temporary directory: %s-*.git (%v)" , prefix , err )
35+ return "" , fmt .Errorf ("Failed to create dir %s-*.git: %v" , prefix , err )
36+
3537 }
3638 return basePath , nil
3739}
0 commit comments