1
0
Fork 0
forked from forgejo/forgejo

#2558 delete local wiki copy when rename repo and user

This commit is contained in:
Unknwon 2016-02-05 14:11:53 -05:00
parent 4e96a4a62b
commit f8182ac521
6 changed files with 40 additions and 25 deletions

View file

@ -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))