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

updater.go: replace os.WriteFile with file.Write() #669

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

udf2457
Copy link
Contributor

@udf2457 udf2457 commented Jan 21, 2025

Ref #667

I also added an explicit file.Close() on the error conditions here because otherwise defer file.Close() would be called after the file.Remove(), IIRC Windows errors if you attempt to remove an open file.

replace os.WriteFile with file.Write()

Signed-off-by: udf2457 <[email protected]>
@udf2457 udf2457 requested a review from a team as a code owner January 21, 2025 16:07
rdimitrov
rdimitrov previously approved these changes Jan 22, 2025
@kommendorkapten
Copy link
Member

This looks good, but I'm thinking about the defer file.Close() on line 599, we can remove that too right?
As there are no paths now when there is no file.Close(). It's closed explicitly on line 624 before os.Rename().

@udf2457
Copy link
Contributor Author

udf2457 commented Jan 22, 2025

This looks good, but I'm thinking about the defer file.Close() on line 599, we can remove that too right? As there are no paths now when there is no file.Close(). It's closed explicitly on line 624 before os.Rename().

I briefly considered it but ended up focusing my PR on the subject at hand and didn't touch anything surrounding it. I guess you can edit the commit ?

File is closed on all branches in the code, removing this.

Signed-off-by: Fredrik Skogman <[email protected]>
Copy link
Member

@kommendorkapten kommendorkapten left a comment

Choose a reason for hiding this comment

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

Thank you!

@kommendorkapten
Copy link
Member

@rdimitrov would you take an an extra look?

Copy link
Contributor

@rdimitrov rdimitrov left a comment

Choose a reason for hiding this comment

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

Looks good 🚀 I see we can also remove some of the err variables and put the statement in the if condition directly but that's just cosmetics and can be a separate PR.

@kommendorkapten kommendorkapten merged commit 110bec9 into theupdateframework:master Jan 22, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants