Downloaded increments the download count of the share.
(ctx context.Context, share *ent.Share)
| 214 | |
| 215 | // Downloaded increments the download count of the share. |
| 216 | func (c *shareClient) Downloaded(ctx context.Context, share *ent.Share) error { |
| 217 | stm := c.client.Share. |
| 218 | UpdateOneID(share.ID). |
| 219 | AddDownloads(1) |
| 220 | if share.RemainDownloads != nil && *share.RemainDownloads >= 0 { |
| 221 | stm.AddRemainDownloads(-1) |
| 222 | } |
| 223 | _, err := stm.Save(ctx) |
| 224 | return err |
| 225 | } |
| 226 | |
| 227 | func IsValidShare(share *ent.Share) error { |
| 228 | // Check if share is expired |
nothing calls this directly
no test coverage detected