From 185c90df1259ce1bbfd10c0d053a938020b9ff90 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 30 Jan 2017 13:30:04 -0500 Subject: [PATCH] Skip deletion for temporary data when not exist on Windows (#4069) --- models/admin.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/admin.go b/models/admin.go index 68731a243..c9a13eb5d 100644 --- a/models/admin.go +++ b/models/admin.go @@ -77,7 +77,8 @@ func RemoveAllWithNotice(title, path string) { // workaround for Go not being able to remove read-only files/folders: https://github.com/golang/go/issues/9606 // this bug should be fixed on Go 1.7, so the workaround should be removed when Gogs don't support Go 1.6 anymore: // https://github.com/golang/go/commit/2ffb3e5d905b5622204d199128dec06cefd57790 - if setting.IsWindows { + // Note: Windows complains when delete target does not exist, therefore we can skip deletion in such cases. + if setting.IsWindows && com.IsExist(path) { // converting "/" to "\" in path on Windows path = strings.Replace(path, "/", "\\", -1) err = exec.Command("cmd", "/C", "rmdir", "/S", "/Q", path).Run()