Skip to content

Commit

Permalink
fix: use os.Stat to check file existence
Browse files Browse the repository at this point in the history
  • Loading branch information
qazwsxedckll committed Aug 29, 2024
1 parent 205f83b commit b157e4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rotate_file.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package logh

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -64,8 +65,9 @@ func (r *RotateFile) Write(p []byte) (int, error) {
r.count++
if r.count >= r.checkEveryN {
r.count = 0
_, err := os.Open(r.file.Name())
if err != nil {

_, err := os.Stat(r.file.Name())
if errors.Is(err, os.ErrNotExist) {
r.rotate()
}

Expand Down

0 comments on commit b157e4c

Please sign in to comment.