Commit 653f0b6e authored by yanzg's avatar yanzg

文件处理

parent 70b1841f
......@@ -85,25 +85,26 @@ public class YzgFileServiceImpl implements YzgFileService {
@Override
public void removeTempFolder(String tempFolder) {
tempFolder = checkFolder(tempFolder);
String toFolder = fileConfig.getServerFullPath(tempFolder);
// 设置标记
synchronized (cacheRemoveTempFolder) {
if (StringHelper.toBoolean(cacheRemoveTempFolder.get(tempFolder))) {
if (StringHelper.toBoolean(cacheRemoveTempFolder.get(toFolder))) {
return;
}
cacheRemoveTempFolder.put(tempFolder, true);
cacheRemoveTempFolder.put(toFolder, true);
}
try {
// 删除当前临时目录
FileHelper.deleteFolder(tempFolder);
FileHelper.deleteFolder(toFolder);
// 父文件夹不存在子文件时则删除
File file = new File(tempFolder);
File file = new File(toFolder);
File parentFile = file.getParentFile();
if (parentFile.listFiles() == null || parentFile.listFiles().length == 0) {
removeTempFolder(parentFile.getAbsolutePath());
}
} finally {
// 设置已经删除完成
cacheRemoveTempFolder.remove(tempFolder);
cacheRemoveTempFolder.remove(toFolder);
}
}
......
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