-
-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# @Time : 2023/8/15 22:00 | ||
# @Author : Lan | ||
# @File : tasks.py | ||
# @Software: PyCharm | ||
import asyncio | ||
|
||
from tortoise.expressions import Q | ||
|
||
from apps.base.models import FileCodes | ||
from apps.base.utils import error_ip_limit, upload_ip_limit | ||
from core.storage import file_storage | ||
from core.utils import get_now | ||
|
||
|
||
async def delete_expire_files(): | ||
while True: | ||
try: | ||
await error_ip_limit.remove_expired_ip() | ||
await upload_ip_limit.remove_expired_ip() | ||
expire_data = await FileCodes.filter(Q(expired_at__lt=await get_now()) | Q(expired_count=0)).all() | ||
for exp in expire_data: | ||
await file_storage.delete_file(exp) | ||
await exp.delete() | ||
except Exception as e: | ||
print(e) | ||
finally: | ||
await asyncio.sleep(600) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters