Skip to content

Commit 9500083

Browse files
devin-ai-integration[bot]jerry@browserless.io
andcommitted
Fix browser download directory to automatically use /shared-downloads in Docker
- Add model validator to BrowserProfile that sets downloads_path to /shared-downloads in Docker environments - Add Chrome --download-default-directory flag when downloads_path is configured - Ensures downloads go directly to shared directory without manual save_as() calls - Fixes issue where save_as() resulted in empty files due to temp location copying Co-Authored-By: jerry@browserless.io <jerry@browserless.io>
1 parent 4c8e103 commit 9500083

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

browser_use/browser/profile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,13 @@ def warn_storage_state_user_data_dir_conflict(self) -> Self:
642642
)
643643
return self
644644

645+
@model_validator(mode='after')
646+
def set_docker_downloads_path(self) -> Self:
647+
"""Set downloads_path to /shared-downloads in Docker environments if not already set."""
648+
if IN_DOCKER and not self.downloads_path:
649+
self.downloads_path = '/shared-downloads'
650+
return self
651+
645652
def get_args(self) -> list[str]:
646653
if isinstance(self.ignore_default_args, list):
647654
default_args = set(CHROME_DEFAULT_ARGS) - set(self.ignore_default_args)
@@ -669,6 +676,7 @@ def get_args(self) -> list[str]:
669676
if self.window_position
670677
else []
671678
),
679+
*([f'--download-default-directory={self.downloads_path}'] if self.downloads_path else []),
672680
]
673681

674682
final_args_list = BrowserLaunchArgs.args_as_list(BrowserLaunchArgs.args_as_dict(pre_conversion_args))

0 commit comments

Comments
 (0)