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

updaters: handle "unchanged" better #201

Merged
merged 6 commits into from
Jul 13, 2020
Merged

updaters: handle "unchanged" better #201

merged 6 commits into from
Jul 13, 2020

Conversation

hdonnay
Copy link
Member

@hdonnay hdonnay commented Jul 10, 2020

The debian and ubunut updaters weren't actually checking the passed-in fingerprint, which was resulting in spurious updates in the database.

The alpine updater wasn't using an etag, which the remote server seems to support, so this change uses that.

@hdonnay hdonnay requested a review from ldelossa July 10, 2020 21:39
@hdonnay
Copy link
Member Author

hdonnay commented Jul 10, 2020

still need to spot-check the other updaters

@hdonnay hdonnay marked this pull request as ready for review July 13, 2020 18:08
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
@@ -58,18 +58,16 @@ func (u *Updater) Fetch(ctx context.Context, hint driver.Fingerprint) (io.ReadCl

var r io.Reader = res.Body
if _, err := io.Copy(tf, r); err != nil {
tf.Close()
Copy link
Contributor

@ldelossa ldelossa Jul 13, 2020

Choose a reason for hiding this comment

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

Suggested change
tf.Close()
if tf != nil {
tf.Close()
}

I've gotten into the habit of checking nil on these things first, may not be necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, tmp.File works such that if it didn't return an error, it can't return a nil pointer.

}
}

func (f *fingerprint) From(h http.Header) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FromHeader ?

@hdonnay hdonnay merged commit 1b6b49a into master Jul 13, 2020
@hdonnay hdonnay deleted the hank/updaters branch July 13, 2020 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants