diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-07-16 06:39:27 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-07-16 17:48:08 +0000 |
| commit | ba35da1ee97f04f0e9758c1c35e671c06d3658c3 (patch) | |
| tree | 772e423b85eaada19fa500230a901f15264e4d3d /internal/postgres/insert_module.go | |
| parent | c5f4a73335abc18dd5e18bcd005205fcc61640f2 (diff) | |
| download | go-x-pkgsite-ba35da1ee97f04f0e9758c1c35e671c06d3658c3.tar.xz | |
internal/postgres: delete alternative module from search_documents
When inserting a module whose latest version alternative, delete
all versions of the module from search_documents.
Before, we didn't insert the module into search_documents, but
we did not delete other versions of that module.
Change-Id: I87f14b883faf226be151e78605ec44cc216888b6
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/334950
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/postgres/insert_module.go')
| -rw-r--r-- | internal/postgres/insert_module.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go index d11511a3..77114433 100644 --- a/internal/postgres/insert_module.go +++ b/internal/postgres/insert_module.go @@ -149,11 +149,12 @@ func (db *DB) saveModule(ctx context.Context, m *internal.Module, lmv *internal. return err } - // If the most recent version of this module has an alternative - // module path, then do not insert its packages into search_documents. This - // happens when a module that initially does not have a go.mod file is - // forked or fetched via some non-canonical path (such as an alternative - // capitalization), and then in a later version acquires a go.mod file. + // If the most recent version of this module has an alternative module + // path, then do not insert its packages into search_documents (and + // delete whatever is there). This happens when a module that initially + // does not have a go.mod file is forked or fetched via some + // non-canonical path (such as an alternative capitalization), and then + // in a later version acquires a go.mod file. // // To take an actual example: github.com/sirupsen/logrus@v1.1.0 has a go.mod // file that establishes that path as canonical. But v1.0.6 does not have a @@ -175,7 +176,7 @@ func (db *DB) saveModule(ctx context.Context, m *internal.Module, lmv *internal. } if alt { log.Infof(ctx, "%s@%s: not inserting into search documents", m.ModulePath, m.Version) - return nil + return deleteModuleFromSearchDocuments(ctx, tx, m.ModulePath, nil) } // Insert the module's packages into search_documents. if err := upsertSearchDocuments(ctx, tx, m); err != nil { |
