Browse Source

[Improvement][Api] Upload resource to remote failed, the local tmp file need to be cleared #5475 (#5476)

pull/3/MERGE
ruanwenjun 4 years ago committed by GitHub
parent
commit
68301db6b9
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/impl/ResourcesServiceImpl.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/impl/ResourcesServiceImpl.java

@ -600,6 +600,11 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
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

@ -383,7 +383,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