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.
@@ -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.
