diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-08-26 05:51:46 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-08-26 13:55:09 +0000 |
| commit | 0eeccf082fa68b8e061bdd376a923e04d6073d0f (patch) | |
| tree | 57a860895f5cd76f83f18caf76cb7c27a68864fa /internal/fetchdatasource/fetchdatasource.go | |
| parent | ac26f27d709d79ebdecdd54b17fb285579d96377 (diff) | |
| download | go-x-pkgsite-0eeccf082fa68b8e061bdd376a923e04d6073d0f.tar.xz | |
internal/fetchdatasource: GetUnitMeta returns NotFound on missing package
If a module exists but the package path is not in it, return NotFound.
For golang/go#47780
Change-Id: If3a6602df4b99c8470020e8538e01c685880d86d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/345251
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/fetchdatasource/fetchdatasource.go')
| -rw-r--r-- | internal/fetchdatasource/fetchdatasource.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/fetchdatasource/fetchdatasource.go b/internal/fetchdatasource/fetchdatasource.go index 69f803eb..fe2eacca 100644 --- a/internal/fetchdatasource/fetchdatasource.go +++ b/internal/fetchdatasource/fetchdatasource.go @@ -181,10 +181,12 @@ func (ds *FetchDataSource) GetUnitMeta(ctx context.Context, path, requestedModul Path: path, ModuleInfo: module.ModuleInfo, } - if u := findUnit(module, path); u != nil { - um.Name = u.Name - um.IsRedistributable = u.IsRedistributable + u := findUnit(module, path) + if u == nil { + return nil, derrors.NotFound } + um.Name = u.Name + um.IsRedistributable = u.IsRedistributable return um, nil } |
