|
@@ -7,7 +7,6 @@ package models
|
|
|
import (
|
|
|
"fmt"
|
|
|
"os"
|
|
|
- "os/exec"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
@@ -15,7 +14,6 @@ import (
|
|
|
"github.com/go-xorm/xorm"
|
|
|
log "gopkg.in/clog.v1"
|
|
|
|
|
|
- "github.com/gogs/gogs/pkg/setting"
|
|
|
"github.com/gogs/gogs/pkg/tool"
|
|
|
)
|
|
|
|
|
@@ -52,9 +50,9 @@ func (n *Notice) TrStr() string {
|
|
|
|
|
|
|
|
|
func CreateNotice(tp NoticeType, desc string) error {
|
|
|
-
|
|
|
+
|
|
|
if x == nil {
|
|
|
- return fmt.Errorf("Could not save notice due database connection not being available: %d %s", tp, desc)
|
|
|
+ return fmt.Errorf("could not save notice due database connection not being available: %d %s", tp, desc)
|
|
|
}
|
|
|
|
|
|
n := &Notice{
|
|
@@ -73,24 +71,11 @@ func CreateRepositoryNotice(desc string) error {
|
|
|
|
|
|
|
|
|
func RemoveAllWithNotice(title, path string) {
|
|
|
- var err error
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if setting.IsWindows && com.IsExist(path) {
|
|
|
-
|
|
|
- path = strings.Replace(path, "/", "\\", -1)
|
|
|
- err = exec.Command("cmd", "/C", "rmdir", "/S", "/Q", path).Run()
|
|
|
- } else {
|
|
|
- err = os.RemoveAll(path)
|
|
|
- }
|
|
|
-
|
|
|
- if err != nil {
|
|
|
+ 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)
|
|
|
+ log.Error(2, "CreateRepositoryNotice: %v", err)
|
|
|
}
|
|
|
}
|
|
|
}
|