downloaded file debugger accessible (#3338)
This commit is contained in:
@@ -836,6 +836,12 @@ async def handle_click_to_download_file_action(
|
||||
get_download_dir(run_id=context.run_id if context and context.run_id else task.workflow_run_id or task.task_id)
|
||||
)
|
||||
list_files_before = list_files_in_directory(download_dir)
|
||||
if task.browser_session_id:
|
||||
files_in_browser_session = await app.STORAGE.list_downloaded_files_in_browser_session(
|
||||
organization_id=task.organization_id, browser_session_id=task.browser_session_id
|
||||
)
|
||||
list_files_before = list_files_before + files_in_browser_session
|
||||
|
||||
LOG.info(
|
||||
"Number of files in download directory before click",
|
||||
num_downloaded_files_before=len(list_files_before),
|
||||
@@ -868,6 +874,12 @@ async def handle_click_to_download_file_action(
|
||||
async with asyncio.timeout(BROWSER_DOWNLOAD_MAX_WAIT_TIME):
|
||||
while True:
|
||||
list_files_after = list_files_in_directory(download_dir)
|
||||
if task.browser_session_id:
|
||||
files_in_browser_session = await app.STORAGE.list_downloaded_files_in_browser_session(
|
||||
organization_id=task.organization_id, browser_session_id=task.browser_session_id
|
||||
)
|
||||
list_files_after = list_files_after + files_in_browser_session
|
||||
|
||||
if len(list_files_after) > len(list_files_before):
|
||||
LOG.info(
|
||||
"Found new files in download directory after click",
|
||||
@@ -891,6 +903,12 @@ async def handle_click_to_download_file_action(
|
||||
|
||||
# check if there's any file is still downloading
|
||||
downloading_files = list_downloading_files_in_directory(download_dir)
|
||||
if task.browser_session_id:
|
||||
files_in_browser_session = await app.STORAGE.list_downloading_files_in_browser_session(
|
||||
organization_id=task.organization_id, browser_session_id=task.browser_session_id
|
||||
)
|
||||
downloading_files = downloading_files + files_in_browser_session
|
||||
|
||||
if len(downloading_files) == 0:
|
||||
return [ActionSuccess(download_triggered=True)]
|
||||
|
||||
|
||||
@@ -656,13 +656,20 @@ class BrowserState:
|
||||
LOG.info("browser context is created")
|
||||
|
||||
if await self.get_working_page() is None:
|
||||
page: Page | None = None
|
||||
if browser_address and len(self.browser_context.pages) > 0:
|
||||
page = self.browser_context.pages[0]
|
||||
await self.set_working_page(page, 0)
|
||||
else:
|
||||
pages = [
|
||||
http_page
|
||||
for http_page in self.browser_context.pages
|
||||
if urlparse(http_page.url).scheme in ["http", "https"]
|
||||
]
|
||||
if len(pages) > 0:
|
||||
page = pages[0]
|
||||
if page is None:
|
||||
page = await self.browser_context.new_page()
|
||||
await self.set_working_page(page, 0)
|
||||
await self._close_all_other_pages()
|
||||
|
||||
await self.set_working_page(page, 0)
|
||||
await self._close_all_other_pages()
|
||||
|
||||
if url:
|
||||
await self.navigate_to_url(page=page, url=url)
|
||||
|
||||
Reference in New Issue
Block a user