@@ -304,16 +304,28 @@ Set<String> getContigsInInputs(List<File> inputVCFs, Logger log) throws Pipeline
304304 return _contigsInInputs ;
305305 }
306306
307- private void copyToLevelFiles (PipelineJob job , File sourceWorkspace , File destinationWorkspace , boolean overwrite ) throws IOException
307+ private void copyToLevelFiles (PipelineJob job , File sourceWorkspace , File destinationWorkspace , boolean removeOtherFiles , boolean overwriteExisting ) throws IOException
308308 {
309309 job .getLogger ().info ("Copying top-level files from: " + sourceWorkspace .getPath ());
310+ if (removeOtherFiles )
311+ {
312+ for (File f : destinationWorkspace .listFiles ())
313+ {
314+ if (!f .isDirectory ())
315+ {
316+ job .getLogger ().debug ("deleting existing top-level file: " + f .getPath ());
317+ f .delete ();
318+ }
319+ }
320+ }
321+
310322 for (String fn : Arrays .asList ("callset.json" , "vidmap.json" , "vcfheader.vcf" , "__tiledb_workspace.tdb" ))
311323 {
312324 File source = new File (sourceWorkspace , fn );
313325 File dest = new File (destinationWorkspace , fn );
314326 if (dest .exists ())
315327 {
316- if (!overwrite )
328+ if (!overwriteExisting )
317329 {
318330 job .getLogger ().debug ("workspace file exists, will not overwrite: " + dest .getPath ());
319331 continue ;
@@ -459,7 +471,7 @@ else if (genomeIds.isEmpty())
459471 }
460472
461473 File sourceWorkspace = getSourceWorkspace (ctx .getParams (), ctx .getSequenceSupport ());
462- copyWorkspace (ctx , sourceWorkspace , workingDestinationWorkspaceFolder , genome , toDelete , !genomicsDbCompleted );
474+ copyWorkspace (ctx , sourceWorkspace , workingDestinationWorkspaceFolder , genome , toDelete , !genomicsDbCompleted , ! genomicsDbCompleted , ! genomicsDbCompleted );
463475 }
464476 else
465477 {
@@ -589,7 +601,7 @@ else if (genomeIds.isEmpty())
589601
590602 if (!copyToSourceDone .exists ())
591603 {
592- copyWorkspace (ctx , workingDestinationWorkspaceFolder , workspaceLocalDir , genome , toDelete , true );
604+ copyWorkspace (ctx , workingDestinationWorkspaceFolder , workspaceLocalDir , genome , toDelete , true , false , false );
593605
594606 try
595607 {
@@ -637,7 +649,7 @@ else if (genomeIds.isEmpty())
637649 }
638650 }
639651
640- private void copyWorkspace (JobContext ctx , File sourceWorkspace , File destinationWorkspaceFolder , ReferenceGenome genome , Collection <File > toDelete , boolean alwaysPerformRsync ) throws PipelineJobException
652+ private void copyWorkspace (JobContext ctx , File sourceWorkspace , File destinationWorkspaceFolder , ReferenceGenome genome , Collection <File > toDelete , boolean alwaysPerformRsync , boolean overwriteTopLevelFiles , boolean removeExistingTopLevelFiles ) throws PipelineJobException
641653 {
642654 if (!destinationWorkspaceFolder .exists ())
643655 {
@@ -675,7 +687,7 @@ private void copyWorkspace(JobContext ctx, File sourceWorkspace, File destinatio
675687
676688 if (!haveCopiedTopLevelFiles )
677689 {
678- copyToLevelFiles (ctx .getJob (), sourceWorkspace , destinationWorkspaceFolder , false );
690+ copyToLevelFiles (ctx .getJob (), sourceWorkspace , destinationWorkspaceFolder , removeExistingTopLevelFiles , overwriteTopLevelFiles );
679691 haveCopiedTopLevelFiles = true ;
680692 }
681693
0 commit comments