fix: handle zero size (#1888)

This commit is contained in:
Jason Song
2023-07-11 11:35:27 +08:00
committed by GitHub
parent 724ec918c9
commit 8c7c0f53c1
3 changed files with 24 additions and 11 deletions

View File

@@ -15,11 +15,17 @@ func (c *Request) ToCache() *Cache {
if c == nil {
return nil
}
return &Cache{
ret := &Cache{
Key: c.Key,
Version: c.Version,
Size: c.Size,
}
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
}
type Cache struct {