mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Catch os... errors
This commit is contained in:
committed by
Kim "BKC" Carlbäcker
parent
5ab85372da
commit
4ff0db0246
@@ -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
|
||||
|
@@ -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))
|
||||
}
|
||||
|
@@ -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))
|
||||
|
Reference in New Issue
Block a user