未验证 提交 68301db6 编写于 作者: R ruanwenjun 提交者: GitHub

[Improvement][Api] Upload resource to remote failed, the local tmp file need...

[Improvement][Api] Upload resource to remote failed, the local tmp file need to be cleared #5475 (#5476)
上级 d04f4b60
......@@ -600,6 +600,11 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
org.apache.dolphinscheduler.api.utils.FileUtils.copyFile(file, localFilename);
HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true);
} catch (Exception e) {
try {
FileUtils.deleteFile(localFilename);
} catch (IOException ex) {
logger.error("delete local tmp file:{} error", localFilename, ex);
}
logger.error(e.getMessage(), e);
return false;
}
......
......@@ -383,7 +383,10 @@ public class FileUtils {
* @throws IOException in case deletion is unsuccessful
*/
public static void deleteFile(String filename) throws IOException {
org.apache.commons.io.FileUtils.forceDelete(new File(filename));
File file = new File(filename);
if (file.exists()) {
org.apache.commons.io.FileUtils.forceDelete(file);
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册