]> source.dussan.org Git - gitea.git/commitdiff
Workaroud delete folder on Windows. Fix #1738
authorAndrey Nering <andrey.nering@gmail.com>
Sat, 6 Feb 2016 19:25:16 +0000 (17:25 -0200)
committerAndrey Nering <andrey.nering@gmail.com>
Sun, 7 Feb 2016 15:39:32 +0000 (13:39 -0200)
models/admin.go

index 811edde244783aa6515f607b0975947273914b5c..7756cd6ae2501eed33cb407f9d030268fb03fda3 100644 (file)
@@ -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 {