Skip to content

Commit 3546dfd

Browse files
committed
Improve clear_tmp_directory when work_path does not exist
Signed-off-by: Thomas Druez <[email protected]>
1 parent 12424a7 commit 3546dfd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

scanpipe/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def clear_tmp_directory(self):
649649
pipeline Run.
650650
"""
651651
shutil.rmtree(self.tmp_path, ignore_errors=True)
652-
self.tmp_path.mkdir(exist_ok=True)
652+
self.tmp_path.mkdir(parents=True, exist_ok=True)
653653

654654
@property
655655
def input_sources_list(self):

scanpipe/tests/test_models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def test_scanpipe_project_model_clear_tmp_directory(self):
113113
self.assertTrue(self.project1.tmp_path.exists())
114114
self.assertEqual([], list(self.project1.tmp_path.glob("*")))
115115

116+
self.assertTrue(self.project1.tmp_path.exists())
117+
shutil.rmtree(self.project1.work_path, ignore_errors=True)
118+
self.assertFalse(self.project1.tmp_path.exists())
119+
self.project1.clear_tmp_directory()
120+
self.assertTrue(self.project1.tmp_path.exists())
121+
116122
def test_scanpipe_project_model_archive(self):
117123
(self.project1.input_path / "input_file").touch()
118124
(self.project1.codebase_path / "codebase_file").touch()

0 commit comments

Comments
 (0)