Skip to content

Commit a60a22d

Browse files
authored
Merge pull request #66 from common-workflow-language/hotfix-graphviz-cache
Delete GraphViz images from cache when deleting a workflow
2 parents 3fd8852 + 2d5d4cb commit a60a22d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/commonwl/viewer/services/WorkflowService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,19 @@ public class WorkflowService {
4141
private final WorkflowRepository workflowRepository;
4242
private final ROBundleFactory ROBundleFactory;
4343
private final int cacheDays;
44+
private final String graphvizStorage;
4445

4546
@Autowired
4647
public WorkflowService(GitHubService githubService,
4748
WorkflowRepository workflowRepository,
4849
ROBundleFactory ROBundleFactory,
49-
@Value("${cacheDays}") int cacheDays) {
50+
@Value("${cacheDays}") int cacheDays,
51+
@Value("${graphvizStorage}") String graphvizStorage) {
5052
this.githubService = githubService;
5153
this.workflowRepository = workflowRepository;
5254
this.ROBundleFactory = ROBundleFactory;
5355
this.cacheDays = cacheDays;
56+
this.graphvizStorage = graphvizStorage;
5457
}
5558

5659
/**
@@ -105,7 +108,11 @@ public void removeWorkflow(Workflow workflow) {
105108
logger.debug("Failed to delete Research Object Bundle");
106109
}
107110

108-
// TODO: Delete cached graphviz images when serverside graphviz is merged
111+
// Delete cached graphviz images if they exist
112+
File graphvizSvg = new File(graphvizStorage + "/" + workflow.getID() + ".svg");
113+
graphvizSvg.delete();
114+
File graphvizPng = new File(graphvizStorage + "/" + workflow.getID() + ".png");
115+
graphvizPng.delete();
109116

110117
// Remove the workflow from the database
111118
workflowRepository.delete(workflow);

0 commit comments

Comments
 (0)