2023-04-28 23:57:40 +08: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 11:35:27 +08:00
|
|
|
ret := &Cache{
|
2023-04-28 23:57:40 +08:00
|
|
|
Key: c.Key,
|
|
|
|
Version: c.Version,
|
|
|
|
Size: c.Size,
|
|
|
|
}
|
2023-07-11 11:35:27 +08: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 23:57:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Cache struct {
|
2025-08-15 20:26:35 -06:00
|
|
|
ID uint64 `json:"id" boltholdKey:"ID"`
|
|
|
|
Repo string `json:"repo" boltholdIndex:"Repo"`
|
|
|
|
Key string `json:"key"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
Size int64 `json:"cacheSize"`
|
|
|
|
Complete bool `json:"complete"`
|
|
|
|
UsedAt int64 `json:"usedAt"`
|
|
|
|
CreatedAt int64 `json:"createdAt"`
|
|
|
|
WriteIsolationKey string `json:"writeIsolationKey"`
|
2023-04-28 23:57:40 +08:00
|
|
|
}
|