Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close file before rotating in RollingFileLogWriter #433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pm47
Copy link

@pm47 pm47 commented Feb 24, 2025

Otherwise a java.nio.file.FileSystemException will be raised, at least on Windows.

Otherwise a `java.nio.file.FileSystemException` will be raised, at least
on Windows.
rollLogs()
true
} else false
private fun shouldRollLogs(logFilePath: Path): Boolean {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the signature of this function because calling maybeRollLogs(fileSizeOrZero()) seemed cumbersome.

@@ -136,8 +134,8 @@ open class RollingFileLogWriter(
private suspend fun writer() {
val logFilePath = pathForLogIndex(0)

if (fileSystem.exists(logFilePath)) {
maybeRollLogs(fileSizeOrZero(logFilePath))
if (fileSystem.exists(logFilePath) && shouldRollLogs(logFilePath)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT we should just do this:

Suggested change
if (fileSystem.exists(logFilePath) && shouldRollLogs(logFilePath)) {
if (shouldRollLogs(logFilePath)) {

because metadataOrNull() already handled the case where the file doesn't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant