summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2016-02-06 17:25:16 -0200
committerAndrey Nering <andrey.nering@gmail.com>2016-02-07 13:39:32 -0200
commitd37cf09ccd76ac2a8408a9278cc97208e318e02c (patch)
treebd9e06d39a284bc66c962689344a79b1bad6e64d /models
parent10fbb1aa2f641546c4fdaee6c6ef7111586bd4e3 (diff)
downloadgitea-d37cf09ccd76ac2a8408a9278cc97208e318e02c.tar.gz
gitea-d37cf09ccd76ac2a8408a9278cc97208e318e02c.zip
Workaroud delete folder on Windows. Fix #1738
Diffstat (limited to 'models')
-rw-r--r--models/admin.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/models/admin.go b/models/admin.go
index 811edde244..7756cd6ae2 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -7,6 +7,7 @@ package models
import (
"fmt"
"os"
+ "os/exec"
"strings"
"time"
@@ -14,6 +15,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/setting"
)
type NoticeType int
@@ -53,7 +55,14 @@ func CreateRepositoryNotice(desc string) error {
// 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 {
+ var err error
+ if setting.IsWindows {
+ err = exec.Command("cmd", "/C", "rmdir", "/S", "/Q", path).Run()
+ } else {
+ err = os.RemoveAll(path)
+ }
+
+ if err != nil {
desc := fmt.Sprintf("%s [%s]: %v", title, path, err)
log.Warn(desc)
if err = CreateRepositoryNotice(desc); err != nil {