Skip to content

Fix boot time not returning stat file value - #1655

Merged
shirou merged 3 commits into
shirou:masterfrom
govrin:patch-1
Jun 6, 2024
Merged

Fix boot time not returning stat file value#1655
shirou merged 3 commits into
shirou:masterfrom
govrin:patch-1

Conversation

@govrin

@govrin govrin commented May 26, 2024

Copy link
Copy Markdown
Contributor

When BootTimeWithContext is called while cache is disabled, the value retrieved from reading the stat file isn't used. Also, I moved the call to time.Now() closer to where the uptime stat is read, to reduce the time between them. This still isn't perfect.

add missing return statement for boot time value retrieved from stat file. Also move current time fetch to be closer to where the "time since boot file" is read

@shirou shirou left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This PR means "the value of useStatFile is not being used" and that seems correct. It only starts being used from the second time onward when caching is enabled. Indeed, now that you mention it... thank you!

The line for currentTime follows the principle of "defining it close to where it is used," but you might be right that it should be moved closer as there are a few steps in between.

So could you fix the golangci-lint ? After that, I will merge.

@govrin

govrin commented Jun 6, 2024

Copy link
Copy Markdown
Contributor Author

golangci-lint said something about the file not being gci-ed, but when I ran it locally it didn't show this error. I also tried to run gci with the correct settings and it didn't fix the file. Can you run the CI again?

EDIT: Nevermind, found the problem :)

@shirou

shirou commented Jun 6, 2024

Copy link
Copy Markdown
Owner

Great. Thanks a lot!

@shirou
shirou merged commit bf0a7e9 into shirou:master Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants