Commit bce5fcd0 by 钟明宏

'修改文件删除过期的时间差'

parent 6927b2f8
......@@ -23,14 +23,15 @@ public class FileCleanTask {
@Autowired
private SystemFile systemFile;
private final long month = 31 * 24 * 60 * 60 * 1000;
private final long halfYear = 6L * 31 * 24 * 60 * 60 * 1000;
@Scheduled(cron = "0 0 0 1 * ? ")
public void cleanFile() {
File[] files = systemFile.getWwwDir().listFiles();
for (File file : files) {
if ((System.currentTimeMillis() - file.lastModified()) > month) {
logger.warn("开始清理过期文件[{}] 创建时间[{}]",file,DateFormatUtils.format(new Date(file.lastModified()),"yyyy-MM-dd HH:mm:ss"));
if ((System.currentTimeMillis() - file.lastModified()) > halfYear) {
logger.warn("开始清理过期文件[{}] 创建时间[{}]", file, DateFormatUtils.format(file.lastModified(), "yyyy-MM-dd HH:mm:ss"));
systemFile.cleanFile(file.getName());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment