mirror of
https://github.com/Xtao-Labs/misskey2telegram.git
synced 2024-11-22 05:53:09 +00:00
fix: delete job time
This commit is contained in:
parent
8eeb844a90
commit
c5f23fbdaf
@ -1,4 +1,5 @@
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
|
||||
@ -10,7 +11,14 @@ async def delete_file(file: str):
|
||||
os.remove(file)
|
||||
|
||||
|
||||
def add_delete_file_job(file: str, seconds: int = 10 * 60):
|
||||
def add_delete_file_job(file: str, seconds: int = 60 * 60):
|
||||
if job := scheduler.get_job(f"df_{file}"):
|
||||
job.remove()
|
||||
scheduler.add_job(delete_file, "interval", args=[file], seconds=seconds, id=f"df_{file}")
|
||||
scheduler.add_job(
|
||||
delete_file,
|
||||
"date",
|
||||
run_date=datetime.now() + timedelta(seconds=seconds),
|
||||
args=(file,),
|
||||
id=f"df_{file}",
|
||||
name=f"df_{file}",
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user