|
18 | 18 | import org.labkey.api.pipeline.AbstractTaskFactorySettings; |
19 | 19 | import org.labkey.api.pipeline.PipeRoot; |
20 | 20 | import org.labkey.api.pipeline.PipelineJob; |
| 21 | +import org.labkey.api.pipeline.PipelineJobException; |
21 | 22 | import org.labkey.api.pipeline.PipelineJobService; |
22 | 23 | import org.labkey.api.pipeline.PipelineService; |
23 | 24 | import org.labkey.api.pipeline.PipelineStatusFile; |
|
33 | 34 | import org.labkey.api.util.PageFlowUtil; |
34 | 35 | import org.labkey.api.view.ActionURL; |
35 | 36 | import org.labkey.api.view.ViewBackgroundInfo; |
| 37 | +import org.labkey.api.writer.PrintWriters; |
36 | 38 | import org.labkey.sequenceanalysis.SequenceAnalysisSchema; |
37 | 39 | import org.labkey.sequenceanalysis.util.SequenceUtil; |
38 | 40 |
|
39 | 41 | import java.io.File; |
40 | 42 | import java.io.FileFilter; |
| 43 | +import java.io.IOException; |
| 44 | +import java.io.PrintWriter; |
41 | 45 | import java.net.URI; |
42 | 46 | import java.net.URISyntaxException; |
43 | 47 | import java.sql.ResultSet; |
@@ -131,7 +135,7 @@ public boolean isJobComplete(PipelineJob job) |
131 | 135 | } |
132 | 136 |
|
133 | 137 | @Override |
134 | | - public RecordedActionSet run() |
| 138 | + public RecordedActionSet run() throws PipelineJobException |
135 | 139 | { |
136 | 140 | getJob().getLogger().info("## The following sections list any files or pipeline jobs that appear to be orphans, not connected to any imported readsets or sequence outputs:"); |
137 | 141 |
|
@@ -205,8 +209,25 @@ public RecordedActionSet run() |
205 | 209 | if (!probableDeletes.isEmpty()) |
206 | 210 | { |
207 | 211 | StringBuilder sb = new StringBuilder(); |
| 212 | + File output = new File(getJob().getLogFile().getParentFile(), "toRemove.sh"); |
| 213 | + try (PrintWriter writer = PrintWriters.getPrintWriter(output)) |
| 214 | + { |
| 215 | + writer.println("#!/bin/bash"); |
| 216 | + writer.println(""); |
| 217 | + writer.println("set -e"); |
| 218 | + writer.println("set -x"); |
| 219 | + writer.println(""); |
| 220 | + probableDeletes.forEach(f -> writer.println("rm -Rf " + f.getPath())); |
| 221 | + } |
| 222 | + catch (IOException e) |
| 223 | + { |
| 224 | + throw new PipelineJobException(e); |
| 225 | + } |
| 226 | + |
208 | 227 | probableDeletes.forEach(f -> sb.append("\n").append(f.getPath())); |
209 | | - getJob().getLogger().info("## The following files can almost certainly be deleted; however, please exercise caution:" + sb.toString()); |
| 228 | + getJob().getLogger().info("## The following files can almost certainly be deleted; however, please exercise caution. Note: the file toRemove.sh has been written and can be executed to remove these:" + sb.toString()); |
| 229 | + |
| 230 | + |
210 | 231 | } |
211 | 232 |
|
212 | 233 | return new RecordedActionSet(); |
|
0 commit comments