@@ -21,19 +21,21 @@ type relengResponse struct {
2121}
2222
2323type relengRelease struct {
24- Version string `json:"version"`
25- Available bool `json:"available"`
26- Info string `json:"info"`
27- Created string `json:"created"`
28- ReleaseDate string `json:"release_date"`
29- KernelVersion * string `json:"kernel_version"`
30- ISOUrl * string `json:"iso_url"`
31- SHA1Sum * string `json:"sha1_sum"`
32- SHA256Sum * string `json:"sha256_sum"`
33- B2Sum * string `json:"b2_sum"`
34- TorrentURL * string `json:"torrent_url"`
35- MagnetURI * string `json:"magnet_uri"`
36- Torrent * relengTorrent `json:"torrent"`
24+ Version string `json:"version"`
25+ Available bool `json:"available"`
26+ Info string `json:"info"`
27+ Created string `json:"created"`
28+ ReleaseDate string `json:"release_date"`
29+ KernelVersion * string `json:"kernel_version"`
30+ ISOUrl * string `json:"iso_url"`
31+ SHA1Sum * string `json:"sha1_sum"`
32+ SHA256Sum * string `json:"sha256_sum"`
33+ B2Sum * string `json:"b2_sum"`
34+ TorrentURL * string `json:"torrent_url"`
35+ MagnetURI * string `json:"magnet_uri"`
36+ PGPFingerprint * string `json:"pgp_fingerprint"`
37+ WKDEmail * string `json:"wkd_email"`
38+ Torrent * relengTorrent `json:"torrent"`
3739}
3840
3941type relengTorrent struct {
@@ -42,11 +44,13 @@ type relengTorrent struct {
4244}
4345
4446var (
45- versionRe = regexp .MustCompile (`^[0-9]+[\.\-\w]+$` )
46- kernelVersionRe = regexp .MustCompile (`^[\d\.]{5,10}$` )
47- sha1Re = regexp .MustCompile (`^[0-9a-f]{40}$` )
48- sha256Re = regexp .MustCompile (`^[0-9a-f]{64}$` )
49- b2Re = regexp .MustCompile (`^[0-9a-f]{128}$` )
47+ versionRe = regexp .MustCompile (`^[0-9]+[\.\-\w]+$` )
48+ kernelVersionRe = regexp .MustCompile (`^[\d\.]{5,10}$` )
49+ sha1Re = regexp .MustCompile (`^[0-9a-f]{40}$` )
50+ sha256Re = regexp .MustCompile (`^[0-9a-f]{64}$` )
51+ b2Re = regexp .MustCompile (`^[0-9a-f]{128}$` )
52+ pgpFingerprintRe = regexp .MustCompile (`^[0-9A-F]{40}$` )
53+ emailRe = regexp .MustCompile (`^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$` )
5054)
5155
5256func Update (ctx context.Context , db * sql.DB ) error {
@@ -64,14 +68,15 @@ func Update(ctx context.Context, db *sql.DB) error {
6468 defer func () { _ = tx .Rollback () }()
6569
6670 stmt , err := tx .PrepareContext (ctx ,
67- `INSERT INTO release (version, available, info, created, release_date, kernel_version, file_name, file_length, sha1_sum, sha256_sum, b2_sum, torrent_url, magnet_uri)
68- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
71+ `INSERT INTO release (version, available, info, created, release_date, kernel_version, file_name, file_length, sha1_sum, sha256_sum, b2_sum, torrent_url, magnet_uri, pgp_fingerprint, wkd_email )
72+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
6973 ON CONFLICT (version) DO UPDATE SET
7074 available = excluded.available, info = excluded.info, created = excluded.created,
7175 release_date = excluded.release_date, kernel_version = excluded.kernel_version,
7276 file_name = excluded.file_name, file_length = excluded.file_length,
7377 sha1_sum = excluded.sha1_sum, sha256_sum = excluded.sha256_sum, b2_sum = excluded.b2_sum,
74- torrent_url = excluded.torrent_url, magnet_uri = excluded.magnet_uri` )
78+ torrent_url = excluded.torrent_url, magnet_uri = excluded.magnet_uri,
79+ pgp_fingerprint = excluded.pgp_fingerprint, wkd_email = excluded.wkd_email` )
7580 if err != nil {
7681 return err
7782 }
@@ -112,12 +117,15 @@ func Update(ctx context.Context, db *sql.DB) error {
112117 sha1Sum := matchOrNil (r .SHA1Sum , sha1Re )
113118 sha256Sum := matchOrNil (r .SHA256Sum , sha256Re )
114119 b2Sum := matchOrNil (r .B2Sum , b2Re )
120+ pgpFingerprint := matchOrNil (r .PGPFingerprint , pgpFingerprintRe )
121+ wkdEmail := matchOrNil (r .WKDEmail , emailRe )
115122
116123 if _ , err := stmt .ExecContext (ctx ,
117124 r .Version , r .Available , info , created , releaseDate ,
118125 kernelVersion , fileName , fileLength ,
119126 sha1Sum , sha256Sum , b2Sum ,
120127 torrentURL , r .MagnetURI ,
128+ pgpFingerprint , wkdEmail ,
121129 ); err != nil {
122130 return err
123131 }
0 commit comments