mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	Workaroud delete folder on Windows. Fix #1738
This commit is contained in:
		| @@ -7,6 +7,7 @@ package models | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"os/exec" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| @@ -14,6 +15,7 @@ import ( | |||||||
|  |  | ||||||
| 	"github.com/gogits/gogs/modules/base" | 	"github.com/gogits/gogs/modules/base" | ||||||
| 	"github.com/gogits/gogs/modules/log" | 	"github.com/gogits/gogs/modules/log" | ||||||
|  | 	"github.com/gogits/gogs/modules/setting" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type NoticeType int | type NoticeType int | ||||||
| @@ -53,7 +55,14 @@ func CreateRepositoryNotice(desc string) error { | |||||||
| // RemoveAllWithNotice removes all directories in given path and | // RemoveAllWithNotice removes all directories in given path and | ||||||
| // creates a system notice when error occurs. | // creates a system notice when error occurs. | ||||||
| func RemoveAllWithNotice(title, path string) { | 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) | 		desc := fmt.Sprintf("%s [%s]: %v", title, path, err) | ||||||
| 		log.Warn(desc) | 		log.Warn(desc) | ||||||
| 		if err = CreateRepositoryNotice(desc); err != nil { | 		if err = CreateRepositoryNotice(desc); err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user