LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package build | 5 package build |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "compress/gzip" | 9 "compress/gzip" |
10 "crypto/sha1" | 10 "crypto/sha1" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if c.ParentHash != "" && !validHash(c.ParentHash) { // empty is OK | 116 if c.ParentHash != "" && !validHash(c.ParentHash) { // empty is OK |
117 return errors.New("invalid ParentHash") | 117 return errors.New("invalid ParentHash") |
118 } | 118 } |
119 return nil | 119 return nil |
120 } | 120 } |
121 | 121 |
122 // each result line is approx 105 bytes. This constant is a tradeoff between | 122 // each result line is approx 105 bytes. This constant is a tradeoff between |
123 // build history and the AppEngine datastore limit of 1mb. | 123 // build history and the AppEngine datastore limit of 1mb. |
124 const maxResults = 1000 | 124 const maxResults = 1000 |
125 | 125 |
126 // AddResult adds the denormalized Reuslt data to the Commit's Result field. | 126 // AddResult adds the denormalized Result data to the Commit's Result field. |
127 // It must be called from inside a datastore transaction. | 127 // It must be called from inside a datastore transaction. |
128 func (com *Commit) AddResult(c appengine.Context, r *Result) error { | 128 func (com *Commit) AddResult(c appengine.Context, r *Result) error { |
129 if err := datastore.Get(c, com.Key(c), com); err != nil { | 129 if err := datastore.Get(c, com.Key(c), com); err != nil { |
130 return fmt.Errorf("getting Commit: %v", err) | 130 return fmt.Errorf("getting Commit: %v", err) |
131 } | 131 } |
132 com.ResultData = trim(append(com.ResultData, r.Data()), maxResults) | 132 com.ResultData = trim(append(com.ResultData, r.Data()), maxResults) |
133 if _, err := datastore.Put(c, com.Key(c), com); err != nil { | 133 if _, err := datastore.Put(c, com.Key(c), com); err != nil { |
134 return fmt.Errorf("putting Commit: %v", err) | 134 return fmt.Errorf("putting Commit: %v", err) |
135 } | 135 } |
136 return nil | 136 return nil |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 break | 321 break |
322 } else if err != nil { | 322 } else if err != nil { |
323 return nil, err | 323 return nil, err |
324 } | 324 } |
325 if pkg.Path != "" { | 325 if pkg.Path != "" { |
326 pkgs = append(pkgs, pkg) | 326 pkgs = append(pkgs, pkg) |
327 } | 327 } |
328 } | 328 } |
329 return pkgs, nil | 329 return pkgs, nil |
330 } | 330 } |
LEFT | RIGHT |