1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 14:50:55 +00:00

Merge pull request #3818 from dbt4516/develop

Get the real location of the log directory before using filepath.Walk function when remove old logs
This commit is contained in:
Ming Deng 2020-06-23 21:17:14 +08:00 committed by GitHub
commit 96658121dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -359,6 +359,10 @@ RESTART_LOGGER:
func (w *fileLogWriter) deleteOldLog() { func (w *fileLogWriter) deleteOldLog() {
dir := filepath.Dir(w.Filename) dir := filepath.Dir(w.Filename)
absolutePath, err := filepath.EvalSymlinks(w.Filename)
if err == nil {
dir = filepath.Dir(absolutePath)
}
filepath.Walk(dir, func(path string, info os.FileInfo, err error) (returnErr error) { filepath.Walk(dir, func(path string, info os.FileInfo, err error) (returnErr error) {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {