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

Refactor blobCacheDestination.saveStream #2380

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Apr 17, 2024

Prefer defer, and early returns, and straight-line code.

Effectively this is just one small bug fix (a nil reference on an error path)

The problem this is aiming to address is that nothing between initially creating err3 and the code that removes the temporary file is allowed to return; i.e. adding new reasons for the function to fail is hard.

mtrmac added 2 commits April 18, 2024 00:42
Use defer() to remove the temporary file, instead
of duplicating the call.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
Use defer, a nested function, and early returns.

Besides being a bit more directly related to what
we want to achieve, this now does not call decompressed.Close()
on a nil value if DecompressStream fails.

Signed-off-by: Miloslav Trmač <[email protected]>
@mtrmac mtrmac added the kind/bug A defect in an existing functionality (or a PR fixing it) label Apr 17, 2024
@rhatdan
Copy link
Member

rhatdan commented Apr 20, 2024

LGTM
@giuseppe PTAL

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A defect in an existing functionality (or a PR fixing it)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants