mirror of
https://github.com/golang/go
synced 2024-11-07 01:46:15 -07:00
707c7629cb
LGTM=dsymonds R=golang-codereviews, dsymonds CC=golang-codereviews https://golang.org/cl/104780044
47 lines
928 B
Go
47 lines
928 B
Go
// Copyright 2012 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build appengine
|
|
|
|
package build
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"appengine"
|
|
"appengine/datastore"
|
|
|
|
"cache"
|
|
"key"
|
|
)
|
|
|
|
func initHandler(w http.ResponseWriter, r *http.Request) {
|
|
d := dashboardForRequest(r)
|
|
c := d.Context(appengine.NewContext(r))
|
|
defer cache.Tick(c)
|
|
for _, p := range d.Packages {
|
|
err := datastore.Get(c, p.Key(c), new(Package))
|
|
if _, ok := err.(*datastore.ErrFieldMismatch); ok {
|
|
// Some fields have been removed, so it's okay to ignore this error.
|
|
err = nil
|
|
}
|
|
if err == nil {
|
|
continue
|
|
} else if err != datastore.ErrNoSuchEntity {
|
|
logErr(w, r, err)
|
|
return
|
|
}
|
|
if _, err := datastore.Put(c, p.Key(c), p); err != nil {
|
|
logErr(w, r, err)
|
|
return
|
|
}
|
|
}
|
|
|
|
// Create secret key.
|
|
key.Secret(c)
|
|
|
|
fmt.Fprint(w, "OK")
|
|
}
|