aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/log/file.go5
-rw-r--r--modules/log/log.go7
-rw-r--r--modules/ssh/ssh.go7
3 files changed, 16 insertions, 3 deletions
diff --git a/modules/log/file.go b/modules/log/file.go
index 563abc28f8..dc243de8d9 100644
--- a/modules/log/file.go
+++ b/modules/log/file.go
@@ -219,7 +219,10 @@ func (w *FileLogWriter) deleteOldLog() {
if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) {
if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
- os.Remove(path)
+
+ if err := os.Remove(path); err != nil {
+ returnErr = fmt.Errorf("Fail to remove %s: %v", path, err)
+ }
}
}
return returnErr
diff --git a/modules/log/log.go b/modules/log/log.go
index 5a9efe6a28..6ca6d3f7c1 100644
--- a/modules/log/log.go
+++ b/modules/log/log.go
@@ -42,7 +42,12 @@ func NewLogger(bufLen int64, mode, config string) {
// NewGitLogger create a logger for git
// FIXME: use same log level as other loggers.
func NewGitLogger(logPath string) {
- os.MkdirAll(path.Dir(logPath), os.ModePerm)
+ path := path.Dir(logPath)
+
+ if err := os.MkdirAll(path, os.ModePerm); err != nil {
+ Fatal(4, "Fail to create dir %s: %v", path, err)
+ }
+
GitLogger = newLogger(0)
GitLogger.SetLogger("file", fmt.Sprintf(`{"level":0,"filename":"%s","rotate":false}`, logPath))
}
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go
index 0781073f59..b35973cc32 100644
--- a/modules/ssh/ssh.go
+++ b/modules/ssh/ssh.go
@@ -162,7 +162,12 @@ func Listen(port int) {
keyPath := filepath.Join(setting.AppDataPath, "ssh/gogs.rsa")
if !com.IsExist(keyPath) {
- os.MkdirAll(filepath.Dir(keyPath), os.ModePerm)
+ filePath := filepath.Dir(keyPath)
+
+ if err := os.MkdirAll(filePath, os.ModePerm); err != nil {
+ log.Error(4, "Fail to create dir %s: %v", filePath, err)
+ }
+
_, stderr, err := com.ExecCmd("ssh-keygen", "-f", keyPath, "-t", "rsa", "-N", "")
if err != nil {
panic(fmt.Sprintf("Fail to generate private key: %v - %s", err, stderr))