
package cn.orionsec.ops.task.fixed;

import cn.orionsec.kit.lang.utils.time.Dates;
import cn.orionsec.ops.constant.common.EnableType;
import cn.orionsec.ops.constant.system.SystemEnvAttr;
import cn.orionsec.ops.utils.FileCleaner;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AutoCleanFileTask {

    @Scheduled(cron = "0 30 1 * * ?")
    private void cleanHandler() {
        if (!EnableType.of(SystemEnvAttr.ENABLE_AUTO_CLEAN_FILE.getValue()).getValue()) {
            return;
        }
        log.info("自动清理文件-开始 {}", Dates.current());
        FileCleaner.cleanAll();
        log.info("自动清理文件-结束 {}", Dates.current());
    }

}
