summaryrefslogtreecommitdiffstats
path: root/models/admin.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-02-05 14:11:53 -0500
committerUnknwon <u@gogs.io>2016-02-05 14:11:53 -0500
commitf8182ac5216153f9ac6dbfe31437b03ddadbf286 (patch)
treea18bc6c2e250fc4b39f85c0427ab3b5ddb9b21c3 /models/admin.go
parent4e96a4a62b1bfbe07bc97e75478c1289f6b4d5a9 (diff)
downloadgitea-f8182ac5216153f9ac6dbfe31437b03ddadbf286.tar.gz
gitea-f8182ac5216153f9ac6dbfe31437b03ddadbf286.zip
#2558 delete local wiki copy when rename repo and user
Diffstat (limited to 'models/admin.go')
-rw-r--r--models/admin.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/admin.go b/models/admin.go
index 1d6bf62961..811edde244 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -5,12 +5,15 @@
package models
import (
+ "fmt"
+ "os"
"strings"
"time"
"github.com/Unknwon/com"
"github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/log"
)
type NoticeType int
@@ -47,6 +50,18 @@ func CreateRepositoryNotice(desc string) error {
return CreateNotice(NOTICE_REPOSITORY, desc)
}
+// RemoveAllWithNotice removes all directories in given path and
+// creates a system notice when error occurs.
+func RemoveAllWithNotice(title, path string) {
+ if err := os.RemoveAll(path); err != nil {
+ desc := fmt.Sprintf("%s [%s]: %v", title, path, err)
+ log.Warn(desc)
+ if err = CreateRepositoryNotice(desc); err != nil {
+ log.Error(4, "CreateRepositoryNotice: %v", err)
+ }
+ }
+}
+
// CountNotices returns number of notices.
func CountNotices() int64 {
count, _ := x.Count(new(Notice))