2023-04-28 15:57:40 +00:00
|
|
|
package artifactcache
|
|
|
|
|
|
|
|
type Request struct {
|
|
|
|
Key string `json:"key" `
|
|
|
|
Version string `json:"version"`
|
|
|
|
Size int64 `json:"cacheSize"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Request) ToCache() *Cache {
|
|
|
|
if c == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2023-07-11 03:35:27 +00:00
|
|
|
ret := &Cache{
|
2023-04-28 15:57:40 +00:00
|
|
|
Key: c.Key,
|
|
|
|
Version: c.Version,
|
|
|
|
Size: c.Size,
|
|
|
|
}
|
2023-07-11 03:35:27 +00:00
|
|
|
if c.Size == 0 {
|
|
|
|
// So the request comes from old versions of actions, like `actions/cache@v2`.
|
|
|
|
// It doesn't send cache size. Set it to -1 to indicate that.
|
|
|
|
ret.Size = -1
|
|
|
|
}
|
|
|
|
return ret
|
2023-04-28 15:57:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Cache struct {
|
2024-03-28 16:42:02 +00:00
|
|
|
ID uint64 `json:"id" boltholdKey:"ID"`
|
|
|
|
Key string `json:"key" boltholdIndex:"Key"`
|
|
|
|
Version string `json:"version" boltholdIndex:"Version"`
|
|
|
|
Size int64 `json:"cacheSize"`
|
|
|
|
Complete bool `json:"complete" boltholdIndex:"Complete"`
|
|
|
|
UsedAt int64 `json:"usedAt" boltholdIndex:"UsedAt"`
|
|
|
|
CreatedAt int64 `json:"createdAt" boltholdIndex:"CreatedAt"`
|
2023-04-28 15:57:40 +00:00
|
|
|
}
|