-
Notifications
You must be signed in to change notification settings - Fork 384
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
Fixes to storage’s GetBlob
#2394
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,12 +107,11 @@ func (s *storageImageSource) Close() error { | |
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown). | ||
// The Digest field in BlobInfo is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided. | ||
// May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location. | ||
func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (rc io.ReadCloser, n int64, err error) { | ||
func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) { | ||
// We need a valid digest value. | ||
digest := info.Digest | ||
|
||
err = digest.Validate() | ||
if err != nil { | ||
if err := digest.Validate(); err != nil { | ||
return nil, 0, err | ||
} | ||
|
||
|
@@ -154,7 +153,7 @@ func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, c | |
// NOTE: the blob is first written to a temporary file and subsequently | ||
// closed. The intention is to keep the time we own the storage lock | ||
// as short as possible to allow other processes to access the storage. | ||
rc, n, _, err = s.getBlobAndLayerID(digest, layers) | ||
rc, n, _, err := s.getBlobAndLayerID(digest, layers) | ||
if err != nil { | ||
return nil, 0, err | ||
} | ||
|
@@ -177,7 +176,7 @@ func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo, c | |
// On Unix and modern Windows (2022 at least) we can eagerly unlink the file to ensure it's automatically | ||
// cleaned up on process termination (or if the caller forgets to invoke Close()) | ||
// On older versions of Windows we will have to fallback to relying on the caller to invoke Close() | ||
if err := os.Remove(tmpFile.Name()); err != nil { | ||
if err := os.Remove(tmpFile.Name()); err == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had found myself scratching my head over this logic too but had set it aside because it didn't seem directly relevant to the issue at hand. |
||
tmpFileRemovePending = false | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A combination of several deferred calls, and a return value that's a direct function call, which itself takes an unnamed function, makes these named return values treacherously confusing. :)