diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-24 23:19:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-24 23:19:13 +0800 |
commit | c0ea3963be91dbd1f436d390ce5223c7ad116479 (patch) | |
tree | 4cc1829880da2a94de7ede227f0d4b3a17566600 /models/repo.go | |
parent | 0602a44b276b009c1f7eb65c589ec284ef4131cf (diff) | |
download | gitea-c0ea3963be91dbd1f436d390ce5223c7ad116479.tar.gz gitea-c0ea3963be91dbd1f436d390ce5223c7ad116479.zip |
fix delete repo will hang on postgres (#1044)
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/models/repo.go b/models/repo.go index e276a87ae6..3a1f149199 100644 --- a/models/repo.go +++ b/models/repo.go @@ -412,13 +412,18 @@ func (repo *Repository) ComposeMetas() map[string]string { } // DeleteWiki removes the actual and local copy of repository wiki. -func (repo *Repository) DeleteWiki() { +func (repo *Repository) DeleteWiki() error { + return repo.deleteWiki(x) +} + +func (repo *Repository) deleteWiki(e Engine) error { wikiPaths := []string{repo.WikiPath(), repo.LocalWikiPath()} for _, wikiPath := range wikiPaths { - RemoveAllWithNotice("Delete repository wiki", wikiPath) + removeAllWithNotice(e, "Delete repository wiki", wikiPath) } - x.Where("repo_id = ?", repo.ID).And("type = ?", UnitTypeWiki).Delete(new(RepoUnit)) + _, err := e.Where("repo_id = ?", repo.ID).And("type = ?", UnitTypeWiki).Delete(new(RepoUnit)) + return err } func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) { @@ -1620,27 +1625,25 @@ func DeleteRepository(uid, repoID int64) error { return err } - // Remove repository files. + // FIXME: Remove repository files should be executed after transaction succeed. repoPath := repo.repoPath(sess) - RemoveAllWithNotice("Delete repository files", repoPath) + removeAllWithNotice(sess, "Delete repository files", repoPath) - repo.DeleteWiki() + repo.deleteWiki(sess) // Remove attachment files. for i := range attachmentPaths { - RemoveAllWithNotice("Delete attachment", attachmentPaths[i]) + removeAllWithNotice(sess, "Delete attachment", attachmentPaths[i]) } // Remove LFS objects var lfsObjects []*LFSMetaObject - if err = sess.Where("repository_id=?", repoID).Find(&lfsObjects); err != nil { return err } for _, v := range lfsObjects { count, err := sess.Count(&LFSMetaObject{Oid: v.Oid}) - if err != nil { return err } |