Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(newFile): improve file rotation detection
The current implementation of file rotation detection in the `newFile` function is prone to race conditions and is not reliable. This change addresses this issue by using `os.Stat` on the file descriptor of the open file to check for rotation, rather than using `os.Open` and `os.Stat` separately. This eliminates the race condition and makes the rotation detection more reliable. Additionally, Instead of using `os.SameFile` to check for file rotation, it is now checking for a change in file size and modification time. This will ensure that the rotation detection is more robust and less likely to miss a rotation. This change also includes updating inline comments to provide more context and clarity on the logic of the code.
- Loading branch information