This is an automated email from the ASF dual-hosted git repository.
kirs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 68301db [Improvement][Api] Upload resource to remote failed, the
local tmp file need to be cleared #5475 (#5476)
68301db is described below
commit 68301db6b914ff4002bfbc531c6810864d8e47c2
Author: ruanwenjun <[email protected]>
AuthorDate: Mon May 17 11:13:14 2021 +0800
[Improvement][Api] Upload resource to remote failed, the local tmp file
need to be cleared #5475 (#5476)
---
.../dolphinscheduler/api/service/impl/ResourcesServiceImpl.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/impl/ResourcesServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
index fdae3be..d330601 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@@ -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;
}
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 8c45c21..32e8598 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
@@ -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);
+ }
}
/**