forked from TrueCloudLab/distribution
Merge pull request #1001 from RichardScothern/fix-atrocity
Don't return nil, nil from functions
This commit is contained in:
commit
8a05f9bb4f
3 changed files with 5 additions and 10 deletions
|
@ -211,8 +211,6 @@ func (ms *manifests) Tags() ([]string, error) {
|
|||
}
|
||||
|
||||
return tagsResponse.Tags, nil
|
||||
} else if resp.StatusCode == http.StatusNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, handleErrorResponse(resp)
|
||||
}
|
||||
|
@ -288,7 +286,7 @@ func (ms *manifests) GetByTag(tag string, options ...distribution.ManifestServic
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusNotModified {
|
||||
return nil, nil
|
||||
return nil, distribution.ErrManifestNotModified
|
||||
} else if SuccessStatus(resp.StatusCode) {
|
||||
var sm schema1.SignedManifest
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
|
|
|
@ -603,13 +603,10 @@ func TestManifestFetchWithEtag(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
m2, err := ms.GetByTag("latest", AddEtagToTag("latest", d1.String()))
|
||||
if err != nil {
|
||||
_, err = ms.GetByTag("latest", AddEtagToTag("latest", d1.String()))
|
||||
if err != distribution.ErrManifestNotModified {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m2 != nil {
|
||||
t.Fatal("Expected empty manifest for matching etag")
|
||||
}
|
||||
}
|
||||
|
||||
func TestManifestDelete(t *testing.T) {
|
||||
|
|
|
@ -102,11 +102,11 @@ func (pms proxyManifestStore) GetByTag(tag string, options ...distribution.Manif
|
|||
fromremote:
|
||||
var sm *schema1.SignedManifest
|
||||
sm, err = pms.remoteManifests.GetByTag(tag, client.AddEtagToTag(tag, localDigest.String()))
|
||||
if err != nil {
|
||||
if err != nil && err != distribution.ErrManifestNotModified {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if sm == nil {
|
||||
if err == distribution.ErrManifestNotModified {
|
||||
context.GetLogger(pms.ctx).Debugf("Local manifest for %q is latest, dgst=%s", tag, localDigest.String())
|
||||
return localManifest, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue