summaryrefslogtreecommitdiffstats
path: root/models/helper_directory.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-12-13 22:21:06 +0000
committerAntoine GIRARD <sapk@users.noreply.github.com>2019-12-13 23:21:06 +0100
commit74179d1b5e739b3fa0d0915bb35d6b7596fd13af (patch)
treefd8eb776c254b716a4e2d416bb6903f1c4c90ea7 /models/helper_directory.go
parent8f16a2c37b4f2650f5e9623a92eb368db9564c6f (diff)
downloadgitea-74179d1b5e739b3fa0d0915bb35d6b7596fd13af.tar.gz
gitea-74179d1b5e739b3fa0d0915bb35d6b7596fd13af.zip
Remove SavePatch and generate patches on the fly (#9302)
* Save patches to temporary files * Remove SavePatch and generate patches on the fly * Use ioutil.TempDir * fixup! Use ioutil.TempDir * fixup! fixup! Use ioutil.TempDir * RemoveAll LocalCopyPath() in initIntergrationTest * Default to status checking on PR creation * Remove unnecessary set to StatusChecking * Protect against unable to load repo * Handle conflicts * Restore original conflict setting * In TestPullRequests update status to StatusChecking before running TestPatch
Diffstat (limited to 'models/helper_directory.go')
-rw-r--r--models/helper_directory.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/models/helper_directory.go b/models/helper_directory.go
index 813f0577bc..8119ec91a3 100644
--- a/models/helper_directory.go
+++ b/models/helper_directory.go
@@ -6,15 +6,13 @@ package models
import (
"fmt"
+ "io/ioutil"
"os"
"path"
"path/filepath"
- "time"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
-
- "github.com/unknwon/com"
)
// LocalCopyPath returns the local repository temporary copy path.
@@ -27,11 +25,15 @@ func LocalCopyPath() string {
// CreateTemporaryPath creates a temporary path
func CreateTemporaryPath(prefix string) (string, error) {
- timeStr := com.ToStr(time.Now().Nanosecond()) // SHOULD USE SOMETHING UNIQUE
- basePath := path.Join(LocalCopyPath(), prefix+"-"+timeStr+".git")
- if err := os.MkdirAll(filepath.Dir(basePath), os.ModePerm); err != nil {
- log.Error("Unable to create temporary directory: %s (%v)", basePath, err)
- return "", fmt.Errorf("Failed to create dir %s: %v", basePath, err)
+ if err := os.MkdirAll(LocalCopyPath(), os.ModePerm); err != nil {
+ log.Error("Unable to create localcopypath directory: %s (%v)", LocalCopyPath(), err)
+ return "", fmt.Errorf("Failed to create localcopypath directory %s: %v", LocalCopyPath(), err)
+ }
+ basePath, err := ioutil.TempDir(LocalCopyPath(), prefix+".git")
+ if err != nil {
+ log.Error("Unable to create temporary directory: %s-*.git (%v)", prefix, err)
+ return "", fmt.Errorf("Failed to create dir %s-*.git: %v", prefix, err)
+
}
return basePath, nil
}