Spaces:
Build error
Build error
Update utils/case_manager.py
Browse files- utils/case_manager.py +20 -1
utils/case_manager.py
CHANGED
|
@@ -13,7 +13,26 @@ class CaseManager:
|
|
| 13 |
self.base_path.mkdir(parents=True, exist_ok=True)
|
| 14 |
self.cases = {}
|
| 15 |
self._load_cases()
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def _load_cases(self):
|
| 18 |
"""Load existing cases from storage."""
|
| 19 |
try:
|
|
|
|
| 13 |
self.base_path.mkdir(parents=True, exist_ok=True)
|
| 14 |
self.cases = {}
|
| 15 |
self._load_cases()
|
| 16 |
+
|
| 17 |
+
def delete_case(self, case_id: str) -> bool:
|
| 18 |
+
"""Delete a case and all its associated data."""
|
| 19 |
+
try:
|
| 20 |
+
if case_id not in self.cases:
|
| 21 |
+
raise ValueError(f"Case with ID {case_id} not found")
|
| 22 |
+
|
| 23 |
+
case_path = self.base_path / case_id
|
| 24 |
+
|
| 25 |
+
# Delete all documents in the case directory
|
| 26 |
+
if case_path.exists():
|
| 27 |
+
shutil.rmtree(case_path)
|
| 28 |
+
|
| 29 |
+
# Remove from cases dictionary
|
| 30 |
+
del self.cases[case_id]
|
| 31 |
+
|
| 32 |
+
return True
|
| 33 |
+
except Exception as e:
|
| 34 |
+
raise Exception(f"Error deleting case: {str(e)}")
|
| 35 |
+
|
| 36 |
def _load_cases(self):
|
| 37 |
"""Load existing cases from storage."""
|
| 38 |
try:
|