Skip to content

Commit

Permalink
move purge scheduler to schedulers directory
Browse files Browse the repository at this point in the history
  • Loading branch information
OasisAkari committed Dec 20, 2023
1 parent 905311e commit 21e9da9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
12 changes: 1 addition & 11 deletions modules/core/su_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
from core.component import module
from core.exceptions import TestException
from core.loader import ModulesManager
from core.logger import logger
from core.logger import Logger
from core.parser.message import remove_temp_ban
from core.scheduler import CronTrigger
from core.tos import pardon_user, warn_user
from core.utils.cache import random_cache_path
from core.utils.info import Info
Expand Down Expand Up @@ -167,15 +166,6 @@ async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t("core.message.purge.empty"))


@purge.schedule(CronTrigger.from_crontab('0 0 * * *'))
async def _():
cache_path = os.path.abspath(Config('cache_path'))
Logger.info('Start purging cache...')
if os.path.exists(cache_path):
shutil.rmtree(cache_path)
os.mkdir(cache_path)


set_ = module('set', required_superuser=True, base=True)


Expand Down
15 changes: 15 additions & 0 deletions schedulers/purge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import shutil

from config import Config
from core.logger import Logger
from core.scheduler import Scheduler, CronTrigger


@Scheduler.scheduled_job(CronTrigger.from_crontab('0 0 * * *'))
async def _():
cache_path = os.path.abspath(Config('cache_path'))
Logger.info('Start purging cache...')
if os.path.exists(cache_path):
shutil.rmtree(cache_path)
os.mkdir(cache_path)

0 comments on commit 21e9da9

Please sign in to comment.