Skip to content

Commit

Permalink
fix: 按时间过期问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vastsa committed Jan 11, 2024
1 parent ec0f4c0 commit c6e0d32
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class FileCodes(Model):
created_at: Optional[datetime] = fields.DatetimeField(auto_now_add=True, description='创建时间')

async def is_expired(self):
if self.expired_at and (self.expired_count == -1 or self.expired_count > 0):
# 按时间
if self.expired_at and self.expired_count < 0:
return self.expired_at < await get_now()
# 按次数
else:
return self.expired_count != -1 and self.expired_count == 0

Expand Down

0 comments on commit c6e0d32

Please sign in to comment.