1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 22:30:49 +00:00

remove file bug fixed

remove file by filename and file suffix
This commit is contained in:
JessonChan 2016-03-04 10:43:57 +08:00
parent 2a148473e9
commit 3379a2b7ed

View File

@ -256,7 +256,8 @@ 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)) {
if strings.HasPrefix(filepath.Base(path), w.fileNameOnly) &&
strings.HasSuffix(filepath.Base(path), w.suffix) {
os.Remove(path)
}
}