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/admin.go | |
parent | 0602a44b276b009c1f7eb65c589ec284ef4131cf (diff) | |
download | gitea-c0ea3963be91dbd1f436d390ce5223c7ad116479.tar.gz gitea-c0ea3963be91dbd1f436d390ce5223c7ad116479.zip |
fix delete repo will hang on postgres (#1044)
Diffstat (limited to 'models/admin.go')
-rw-r--r-- | models/admin.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/models/admin.go b/models/admin.go index 94dc9b7a8c..e573c9ba79 100644 --- a/models/admin.go +++ b/models/admin.go @@ -55,27 +55,30 @@ func (n *Notice) TrStr() string { // CreateNotice creates new system notice. func CreateNotice(tp NoticeType, desc string) error { - // prevent panic if database connection is not available at this point - if x == nil { - return fmt.Errorf("Could not save notice due database connection not being available: %d %s", tp, desc) - } + return createNotice(x, tp, desc) +} +func createNotice(e Engine, tp NoticeType, desc string) error { n := &Notice{ Type: tp, Description: desc, } - _, err := x.Insert(n) + _, err := e.Insert(n) return err } // CreateRepositoryNotice creates new system notice with type NoticeRepository. func CreateRepositoryNotice(desc string) error { - return CreateNotice(NoticeRepository, desc) + return createNotice(x, NoticeRepository, desc) } // RemoveAllWithNotice removes all directories in given path and // creates a system notice when error occurs. func RemoveAllWithNotice(title, path string) { + removeAllWithNotice(x, title, path) +} + +func removeAllWithNotice(e Engine, title, path string) { var err error // workaround for Go not being able to remove read-only files/folders: https://github.com/golang/go/issues/9606 // this bug should be fixed on Go 1.7, so the workaround should be removed when Gogs don't support Go 1.6 anymore: @@ -91,7 +94,7 @@ func RemoveAllWithNotice(title, path string) { if err != nil { desc := fmt.Sprintf("%s [%s]: %v", title, path, err) log.Warn(desc) - if err = CreateRepositoryNotice(desc); err != nil { + if err = createNotice(e, NoticeRepository, desc); err != nil { log.Error(4, "CreateRepositoryNotice: %v", err) } } |