MCPcopy Index your code
hub / github.com/nektos/act / commit

Method commit

pkg/artifactcache/handler.go:290–342  ·  view source on GitHub ↗

POST /_apis/artifactcache/caches/:id

(w http.ResponseWriter, r *http.Request, params httprouter.Params)

Source from the content-addressed store, hash-verified

288
289// POST /_apis/artifactcache/caches/:id
290func (h *Handler) commit(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
291 id, err := strconv.ParseInt(params.ByName("id"), 10, 64)
292 if err != nil {
293 h.responseJSON(w, r, 400, err)
294 return
295 }
296
297 cache := &Cache{}
298 db, err := h.openDB()
299 if err != nil {
300 h.responseJSON(w, r, 500, err)
301 return
302 }
303 defer db.Close()
304 if err := db.Get(id, cache); err != nil {
305 if errors.Is(err, bolthold.ErrNotFound) {
306 h.responseJSON(w, r, 400, fmt.Errorf("cache %d: not reserved", id))
307 return
308 }
309 h.responseJSON(w, r, 500, err)
310 return
311 }
312
313 if cache.Complete {
314 h.responseJSON(w, r, 400, fmt.Errorf("cache %v %q: already complete", cache.ID, cache.Key))
315 return
316 }
317
318 db.Close()
319
320 size, err := h.storage.Commit(cache.ID, cache.Size)
321 if err != nil {
322 h.responseJSON(w, r, 500, err)
323 return
324 }
325 // write real size back to cache, it may be different from the current value when the request doesn't specify it.
326 cache.Size = size
327
328 db, err = h.openDB()
329 if err != nil {
330 h.responseJSON(w, r, 500, err)
331 return
332 }
333 defer db.Close()
334
335 cache.Complete = true
336 if err := db.Update(cache.ID, cache); err != nil {
337 h.responseJSON(w, r, 500, err)
338 return
339 }
340
341 h.responseJSON(w, r, 200)
342}
343
344// GET /_apis/artifactcache/artifacts/:id
345func (h *Handler) get(w http.ResponseWriter, r *http.Request, params httprouter.Params) {

Callers

nothing calls this directly

Calls 4

responseJSONMethod · 0.95
openDBMethod · 0.95
CloseMethod · 0.65
CommitMethod · 0.45

Tested by

no test coverage detected