Skip to content

Refactor blobCacheDestination.saveStream#2380

Merged
giuseppe merged 2 commits intocontainers:mainfrom
mtrmac:blobcache-errors
Apr 22, 2024
Merged

Refactor blobCacheDestination.saveStream#2380
giuseppe merged 2 commits intocontainers:mainfrom
mtrmac:blobcache-errors

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č <mitr@redhat.com>
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č <mitr@redhat.com>
@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