From 23ec2ddea295b4d17f6f372c0f31460f3df85b53 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Tue, 18 Aug 2020 09:25:39 -0400 Subject: internal/postgres: don't insert contents of non-redistributable licenses Do not store the contents of a license in the DB if the license does not allow redistribution. Change-Id: I8c3a230f400ad3b4f6492e693dda5e84aa648bdd Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/248957 Reviewed-by: Julie Qiu --- internal/postgres/insert_module.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal/postgres/insert_module.go') diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go index 512c803b..f292feb8 100644 --- a/internal/postgres/insert_module.go +++ b/internal/postgres/insert_module.go @@ -25,6 +25,7 @@ import ( "golang.org/x/pkgsite/internal" "golang.org/x/pkgsite/internal/database" "golang.org/x/pkgsite/internal/derrors" + "golang.org/x/pkgsite/internal/licenses" "golang.org/x/pkgsite/internal/log" "golang.org/x/pkgsite/internal/stdlib" "golang.org/x/pkgsite/internal/version" @@ -713,6 +714,11 @@ func removeNonDistributableData(m *internal.Module) { } } } + for _, l := range m.Licenses { + if !licenses.Redistributable(l.Types) { + l.Contents = nil + } + } } // DeleteModule deletes a Version from the database. -- cgit v1.3-5-g9baa