Skip to content

Commit

Permalink
fix: fix the directory for cleaning files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yves Baldus committed Jun 19, 2024
1 parent 980aa06 commit 648e074
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rotatefile/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (d *Writer) Clean() (err error) {
fileDir, fileName := path.Split(d.cfg.Filepath)

// find and clean old files
err = fsutil.FindInDir(fileDir[:len(fileDir)-2], func(fPath string, ent fs.DirEntry) error {
err = fsutil.FindInDir(fileDir[:len(fileDir)-1], func(fPath string, ent fs.DirEntry) error {
fi, err := ent.Info()
if err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions rotatefile/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func TestWriter_Clean(t *testing.T) {
c.Compress = true
err = wr.Clean()
assert.NoErr(t, err)

files := fsutil.Glob(logfile + ".*")
assert.Equal(t, 2, len(files))
})
}

Expand Down

0 comments on commit 648e074

Please sign in to comment.