This is an automated email from the ASF dual-hosted git repository.
wenhemin pushed a commit to branch 1.3.7-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/1.3.7-prepare by this push:
new 76c4dd9 [1.3.7-prepare#5476][Improvement][Api] Upload resource to
remote failed, the local tmp file need to be cleared (#5848)
76c4dd9 is described below
commit 76c4dd904013e0f1016e3b57942781384d42a4a6
Author: Kirs <[email protected]>
AuthorDate: Tue Jul 20 11:41:49 2021 +0800
[1.3.7-prepare#5476][Improvement][Api] Upload resource to remote failed,
the local tmp file need to be cleared (#5848)
pr #5476
issue #5475
---
.../org/apache/dolphinscheduler/api/service/ResourcesService.java | 5 +++++
.../java/org/apache/dolphinscheduler/common/utils/FileUtils.java | 5 ++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
index e61e7f5..ce430a1 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
@@ -625,6 +625,11 @@ public class ResourcesService extends BaseService {
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;
}
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
index bf47eb8..e64c082 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
@@ -398,7 +398,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);
+ }
}
/**