59773dfa by Francois

Update file.go

New pull request for "Panic sometimes occurs at time 00h00 on windows, then the app crashes."
1 parent a3888cef
...@@ -226,13 +226,20 @@ func (w *FileLogWriter) DoRotate() error { ...@@ -226,13 +226,20 @@ func (w *FileLogWriter) DoRotate() error {
226 226
227 func (w *FileLogWriter) deleteOldLog() { 227 func (w *FileLogWriter) deleteOldLog() {
228 dir := filepath.Dir(w.Filename) 228 dir := filepath.Dir(w.Filename)
229 filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { 229 filepath.Walk(dir, func(path string, info os.FileInfo, err error) (returnErr error) {
230 defer func() {
231 if r := recover(); r != nil {
232 returnErr = fmt.Errorf("Unable to delete old log '%s', error: %+v", path, r)
233 fmt.Println(returnErr)
234 }
235 }()
236
230 if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) { 237 if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) {
231 if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) { 238 if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
232 os.Remove(path) 239 os.Remove(path)
233 } 240 }
234 } 241 }
235 return nil 242 return
236 }) 243 })
237 } 244 }
238 245
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!