Commit be998f94 authored by hongguangwu's avatar hongguangwu

1.7.21-临时文件延迟删除

parent 5327de79
...@@ -205,6 +205,12 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe ...@@ -205,6 +205,12 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
// 此方法是:删除临时文件 // 此方法是:删除临时文件
public void cleanSpireTempFiles() { public void cleanSpireTempFiles() {
try { try {
// 暂停1分钟
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
}
String tempDirPath = System.getProperty("java.io.tmpdir"); String tempDirPath = System.getProperty("java.io.tmpdir");
File tempDir = new File(tempDirPath); File tempDir = new File(tempDirPath);
...@@ -216,12 +222,16 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe ...@@ -216,12 +222,16 @@ public class TSocialFriendPushServiceImpl extends ServiceImpl<TSocialFriendMappe
if (spireTempFiles != null && spireTempFiles.length > 0) { if (spireTempFiles != null && spireTempFiles.length > 0) {
int count = 0; int count = 0;
long totalSize = 0; long totalSize = 0;
long oneMinuteAgo = System.currentTimeMillis() - 60000;
long fileSize;
for (File file : spireTempFiles) { for (File file : spireTempFiles) {
if (file.isFile() && file.canWrite()) { if (file.isFile() && file.canWrite()) {
long fileSize = file.length(); if (file.isFile() && file.canWrite() && file.lastModified() < oneMinuteAgo) {
if (file.delete()) { fileSize = file.length();
count++; if (file.delete()) {
totalSize += fileSize; count++;
totalSize += fileSize;
}
} }
} }
} }
......
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 to comment