Skip to content
Snippets Groups Projects

catch the case where directory no longer exists

Merged Charlotte Hausman requested to merge fix_dir_not_exist_abort_error into main
@@ -115,12 +115,17 @@ class CapoInjector:
path.write_bytes(subspace.content)
logger.info(f"Writing capo subspace file to {self.dir_path.__str__()}")
def clear_subspace(self):
def clear_subspace(self) -> bool:
logger.info(f"Clearing capo subspace file from {self.dir_path.__str__()}...")
for file in os.listdir(self.dir_path):
if file.endswith(".properties"):
Path.unlink(self.dir_path / file)
check = glob.glob("*.properties")
if check is None:
logger.info("Capo subspace cleared successfully.")
if self.dir_path.exists():
for file in os.listdir(self.dir_path):
if file.endswith(".properties"):
Path.unlink(self.dir_path / file)
check = glob.glob("*.properties")
if check is None:
logger.info("Capo subspace cleared successfully.")
return True
else:
logger.info(f"Directory {self.dir_path.__str__()} has already been cleaned.")
return False
Loading