Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Implement data directory cleanup in FileSystem class
mertunsall58c25af1a1fa
diff --git a/browser_use/filesystem/file_system.py b/browser_use/filesystem/file_system.pyindex cfabd19a6..44c5ca49d 100644--- a/browser_use/filesystem/file_system.py+++ b/browser_use/filesystem/file_system.py@@ -1,5 +1,6 @@import asyncioimport re+import shutilfrom abc import ABC, abstractmethodfrom concurrent.futures import ThreadPoolExecutorfrom pathlib import Path@@ -175,10 +176,9 @@ class FileSystem(BaseModel):# Create and use a dedicated subfolder for all operationsdata_dir = base_dir / 'browseruse_agent_data'- if data_dir.exists() and not _restore_mode:- raise ValueError(- 'File system directory already exists - stopping for safety purposes. Please delete it first if you want to use this directory.'- )+ if data_dir.exists():+ # clean the data directory+ shutil.rmtree(data_dir)data_dir.mkdir(exist_ok=True)super().__init__(base_dir=data_dir, **kwargs)