Browse Source

[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
Kirs 3 years ago committed by GitHub
parent
commit
76c4dd9040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
  2. 5
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java

5
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); org.apache.dolphinscheduler.api.utils.FileUtils.copyFile(file, localFilename);
HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true); HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true);
} catch (Exception e) { } catch (Exception e) {
try {
FileUtils.deleteFile(localFilename);
} catch (IOException ex) {
logger.error("delete local tmp file:{} error", localFilename, ex);
}
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return false; return false;
} }

5
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 * @throws IOException in case deletion is unsuccessful
*/ */
public static void deleteFile(String filename) throws IOException { 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);
}
} }
/** /**

Loading…
Cancel
Save