Skip to content

Commit 74f21ec

Browse files
committed
fix: clear policy directory contents instead of removing mount point
shutil.rmtree on the storage directory fails with EBUSY in Docker because the bind-mounted directory is an active mount point. Delete the children individually so the operation works in both Docker and localhost environments. Made-with: Cursor
1 parent a41054b commit 74f21ec

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/backend/policy_library.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,11 @@ def clear(self) -> None:
233233
conn.execute("DELETE FROM policy_documents")
234234
conn.commit()
235235
if self._storage_dir.exists():
236-
shutil.rmtree(self._storage_dir)
236+
for child in self._storage_dir.iterdir():
237+
if child.is_dir():
238+
shutil.rmtree(child)
239+
else:
240+
child.unlink()
237241
self._storage_dir.mkdir(parents=True, exist_ok=True)
238242
self._db_path.parent.mkdir(parents=True, exist_ok=True)
239243
self.initialize()

0 commit comments

Comments
 (0)