diff options
author | Bwko <bouwko@gmail.com> | 2016-12-01 00:56:15 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-12-02 07:41:19 +0100 |
commit | 4ff0db0246fa8a2add1032220024975203b93d72 (patch) | |
tree | 6395dd608ba47cc6429bc12d9595f09ebb915f02 /models/pull.go | |
parent | 5ab85372da74bd95f7143fd59c2c600d4c9894d0 (diff) | |
download | gitea-4ff0db0246fa8a2add1032220024975203b93d72.tar.gz gitea-4ff0db0246fa8a2add1032220024975203b93d72.zip |
Catch os... errors
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/models/pull.go b/models/pull.go index 5157b61fef..eef9a7557b 100644 --- a/models/pull.go +++ b/models/pull.go @@ -218,7 +218,11 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error // Clone base repo. tmpBasePath := path.Join(setting.AppDataPath, "tmp/repos", com.ToStr(time.Now().Nanosecond())+".git") - os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm) + + if err := os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm); err != nil { + return fmt.Errorf("Fail to create dir %s: %v", tmpBasePath, err) + } + defer os.RemoveAll(path.Dir(tmpBasePath)) var stderr string @@ -622,8 +626,11 @@ func (pr *PullRequest) PushToBaseRepo() (err error) { headFile := fmt.Sprintf("refs/pull/%d/head", pr.Index) // Remove head in case there is a conflict. - os.Remove(path.Join(pr.BaseRepo.RepoPath(), headFile)) + file := path.Join(pr.BaseRepo.RepoPath(), headFile) + if err := os.Remove(file); err != nil { + return fmt.Errorf("Fail to remove dir %s: %v", path.Join(pr.BaseRepo.RepoPath(), headFile), err) + } if err = git.Push(headRepoPath, tmpRemoteName, fmt.Sprintf("%s:%s", pr.HeadBranch, headFile)); err != nil { return fmt.Errorf("Push: %v", err) } |