Skip to content

Commit db49996

Browse files
committed
Bugfix to TaskFileManagerImpl when work dir was already cleaned
1 parent 9da4eb1 commit db49996

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

SequenceAnalysis/src/org/labkey/sequenceanalysis/pipeline/TaskFileManagerImpl.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import java.util.HashSet;
5858
import java.util.List;
5959
import java.util.Map;
60+
import java.util.Objects;
6061
import java.util.Set;
6162
import java.util.stream.Collectors;
6263

@@ -250,7 +251,7 @@ private SequenceAnalysisJobSupport getSequenceSupport()
250251

251252
private File getDeferredDeleteLog(boolean create)
252253
{
253-
File logFile = new File(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), "toDelete.txt");
254+
File logFile = FileUtil.appendName(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), "toDelete.txt");
254255
if (create && !logFile.exists())
255256
{
256257
try
@@ -269,7 +270,7 @@ private File getDeferredDeleteLog(boolean create)
269270

270271
private File getMetricsLog(boolean create)
271272
{
272-
File logFile = new File(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), "metricsToCreate.txt");
273+
File logFile = FileUtil.appendName(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), "metricsToCreate.txt");
273274
if (create && !logFile.exists())
274275
{
275276
try (PrintWriter writer = PrintWriters.getPrintWriter(logFile))
@@ -385,10 +386,10 @@ private File convertRelPathToFile(String line)
385386
return null;
386387
}
387388

388-
File f = new File(_workLocation, line);
389+
File f = FileUtil.appendName(_workLocation, line);
389390
if (!f.exists())
390391
{
391-
File test = new File(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), line);
392+
File test = FileUtil.appendName(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), line);
392393
if (test.exists())
393394
{
394395
f = test;
@@ -859,7 +860,7 @@ private void processCopiedFile(File original, File moved, Collection<RecordedAct
859860
_job.getLogger().debug("Directory has " + moved.listFiles().length + " children");
860861
for (File f : moved.listFiles())
861862
{
862-
processCopiedFile(new File(original, f.getName()), f, actions, resumer);
863+
processCopiedFile(FileUtil.appendName(original, f.getName()), f, actions, resumer);
863864
}
864865
}
865866
}
@@ -910,23 +911,21 @@ public void cleanup(Collection<RecordedAction> actions, @Nullable AbstractResume
910911
_job.getLogger().debug("discarding copied inputs");
911912
_wd.discardCopiedInputs();
912913

913-
if (!_wd.getDir().exists())
914+
if (_wd.getDir().exists())
914915
{
915-
throw new PipelineJobException("work dir does not exist: " + _wd.getDir());
916-
}
917-
918-
//NOTE: preserving relative locations is a pain. therefore we copy all outputs, including directories
919-
//then sort out which files were specified as named outputs later
920-
for (File input : _wd.getDir().toNioPathForRead().toFile().listFiles())
921-
{
922-
if (input.getName().matches("^core.[0-9]+$") || input.getName().endsWith(".hprof"))
916+
//NOTE: preserving relative locations is a pain. therefore we copy all outputs, including directories
917+
//then sort out which files were specified as named outputs later
918+
for (File input : Objects.requireNonNull(_wd.getDir().toNioPathForRead().toFile().listFiles()))
923919
{
924-
_job.getLogger().debug("Deleting core/hprof file: " + input.getPath());
925-
input.delete();
926-
continue;
927-
}
920+
if (input.getName().matches("^core.[0-9]+$") || input.getName().endsWith(".hprof"))
921+
{
922+
_job.getLogger().debug("Deleting core/hprof file: " + input.getPath());
923+
input.delete();
924+
continue;
925+
}
928926

929-
copyFile(input, actions, resumer);
927+
copyFile(input, actions, resumer);
928+
}
930929
}
931930
}
932931
else
@@ -987,7 +986,7 @@ private void doCopyFile(File input, Collection<RecordedAction> actions, @Nullabl
987986
}
988987

989988
String path = _wd.getRelativePath(FileSystemLike.wrapFile(input));
990-
File dest = new File(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), path);
989+
File dest = FileUtil.appendName(getSupport().getAnalysisDirectory().toNioPathForRead().toFile(), path);
991990
_job.getLogger().debug("to: " + dest.getPath());
992991

993992
boolean doMove = true;
@@ -1076,7 +1075,7 @@ private File decompressFile(File i, List<RecordedAction> actions)
10761075
//NOTE: we use relative paths in all cases here
10771076
_job.getLogger().info("Decompressing file: " + i.getPath());
10781077

1079-
unzipped = new File(_wd.getDir().toNioPathForRead().toFile(), i.getName().replaceAll(".gz$", ""));
1078+
unzipped = FileUtil.appendName(_wd.getDir().toNioPathForRead().toFile(), i.getName().replaceAll(".gz$", ""));
10801079
unzipped = Compress.decompressGzip(i, unzipped);
10811080
_job.getLogger().debug("\tunzipped: " + unzipped.getPath());
10821081

0 commit comments

Comments
 (0)