|
19 | 19 |
|
20 | 20 | package org.commonwl.view.researchobject;
|
21 | 21 |
|
22 |
| -import org.apache.commons.io.FileUtils; |
23 | 22 | import org.apache.commons.io.FilenameUtils;
|
24 | 23 | import org.apache.taverna.robundle.Bundle;
|
25 | 24 | import org.apache.taverna.robundle.fs.BundleFileSystem;
|
26 | 25 | import org.commonwl.view.git.GitDetails;
|
| 26 | +import org.commonwl.view.util.FileUtils; |
27 | 27 | import org.commonwl.view.workflow.Workflow;
|
28 | 28 | import org.commonwl.view.workflow.WorkflowRepository;
|
29 | 29 | import org.slf4j.Logger;
|
@@ -81,25 +81,10 @@ public void createWorkflowRO(Workflow workflow)
|
81 | 81 |
|
82 | 82 | // Save the bundle to the storage location in properties
|
83 | 83 | Path bundleLocation = roBundleService.saveToFile(bundle);
|
84 |
| - // The RoBundleService#saveToFile call above will delegate to Taverna's |
85 |
| - // Bundles.closeAndSaveBundle, which empties the bundle temporary |
86 |
| - // directory without deleting the directory itself. The following call is |
87 |
| - // just for cleaning it up. |
88 |
| - if (bundle != null) { |
89 |
| - try { |
90 |
| - BundleFileSystem fs = (BundleFileSystem) bundle.getFileSystem(); |
91 |
| - File tmpDir = new File(System.getProperty("java.io.tmpdir")); |
92 |
| - // The file system source will be something like /tmp/bundles_dir/hash/bundle.zip, |
93 |
| - // and we want /tmp/hash to be deleted. N.B. Taverna uses the temporary directory |
94 |
| - // for the temporary bundles' directory, not the bundles file specified by Spring. |
95 |
| - String bundleTmpDirName = fs.getSource().toAbsolutePath().getParent().getFileName().toString(); |
96 |
| - File bundleTmpDir = new File(tmpDir, bundleTmpDirName); |
97 |
| - if (bundleTmpDir.exists() && bundleTmpDir.isDirectory()) { |
98 |
| - FileUtils.forceDelete(bundleTmpDir); |
99 |
| - } |
100 |
| - } catch (IOException e) { |
101 |
| - logger.warn(String.format("Failed to delete temporary directory for bundle [%s]: %s", bundle.getSource(), e.getMessage()), e); |
102 |
| - } |
| 84 | + try { |
| 85 | + FileUtils.deleteBundleTemporaryDirectory(bundle); |
| 86 | + } catch (IOException e) { |
| 87 | + logger.warn(String.format("Failed to delete temporary directory for bundle [%s]: %s", bundle.getSource(), e.getMessage()), e); |
103 | 88 | }
|
104 | 89 |
|
105 | 90 | // Add RO Bundle to associated workflow model
|
|
0 commit comments