Suppress the error when we're removing a file that may not exist
pull/345/head
Bwko 8 years ago
parent c8f300b2cd
commit 0118b275b6
  1. 5
      models/pull.go
  2. 4
      models/wiki.go

@ -712,9 +712,8 @@ func (pr *PullRequest) PushToBaseRepo() (err error) {
// Remove head in case there is a conflict. // Remove head in case there is a conflict.
file := path.Join(pr.BaseRepo.RepoPath(), headFile) file := path.Join(pr.BaseRepo.RepoPath(), headFile)
if err := os.Remove(file); err != nil { _ = os.Remove(file)
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 { if err = git.Push(headRepoPath, tmpRemoteName, fmt.Sprintf("%s:%s", pr.HeadBranch, headFile)); err != nil {
return fmt.Errorf("Push: %v", err) return fmt.Errorf("Push: %v", err)
} }

@ -125,9 +125,7 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
// So we want to make sure the symlink is removed before write anything. // So we want to make sure the symlink is removed before write anything.
// The new file we created will be in normal text format. // The new file we created will be in normal text format.
if err := os.Remove(filename); err != nil { _ = os.Remove(filename)
return fmt.Errorf("Fail to remove %s: %v", filename, err)
}
if err = ioutil.WriteFile(filename, []byte(content), 0666); err != nil { if err = ioutil.WriteFile(filename, []byte(content), 0666); err != nil {
return fmt.Errorf("WriteFile: %v", err) return fmt.Errorf("WriteFile: %v", err)

Loading…
Cancel
Save