@@ -702,6 +702,20 @@ private void alignSet(Readset rs, String basename, Map<ReadData, Pair<File, File
702702 _resumer .setInitialAlignmentDone (bam , alignActions , discardBam );
703703 }
704704
705+ // Because this folder can be large, delete it quickly when possible:
706+ if (getCachedReadDataDir ().exists ())
707+ {
708+ try
709+ {
710+ getJob ().getLogger ().debug ("Deleting cachedReadDataDir" );
711+ FileUtils .deleteDirectory (getCachedReadDataDir ());
712+ }
713+ catch (IOException e )
714+ {
715+ throw new PipelineJobException (e );
716+ }
717+ }
718+
705719 // This is a special case where the alignment does not actually generate a permanent BAM
706720 if (bam == null && discardBam )
707721 {
@@ -1892,8 +1906,34 @@ public void serializeTest() throws Exception
18921906 }
18931907 }
18941908
1909+ private File getCachedReadDataDir ()
1910+ {
1911+ return new File (getHelper ().getWorkingDirectory (), "cachedReadData" );
1912+ }
1913+
18951914 private void restoreArchivedReadDataIfNeeded (Readset rs ) throws PipelineJobException
18961915 {
1916+ if (_resumer .isInitialAlignmentDone ())
1917+ {
1918+ getJob ().getLogger ().debug ("Initial alignment is complete, will not attempt to download SRA if needed" );
1919+
1920+ if (getCachedReadDataDir ().exists ())
1921+ {
1922+ getJob ().getLogger ().debug ("Deleting existing cachedReadDataDir" );
1923+
1924+ try
1925+ {
1926+ FileUtils .deleteDirectory (getCachedReadDataDir ());
1927+ }
1928+ catch (IOException e )
1929+ {
1930+ throw new PipelineJobException (e );
1931+ }
1932+ }
1933+
1934+ return ;
1935+ }
1936+
18971937 Set <String > sraIDs = new HashSet <>();
18981938 for (ReadData rd : rs .getReadData ())
18991939 {
@@ -1947,7 +1987,7 @@ else if (sraIDs.contains(rd.getSra_accession()))
19471987 }
19481988 }
19491989
1950- File outDir = new File ( getHelper (). getWorkingDirectory (), "cachedReadData" );
1990+ File outDir = getCachedReadDataDir ( );
19511991 getTaskFileManagerImpl ().addDeferredIntermediateFile (outDir ); // NOTE: this must be deferred so it remains until the end
19521992
19531993 File doneFile = new File (outDir , rd .getSra_accession () + ".done" );
0 commit comments