Skip to content

Commit

Permalink
fix: retry listing folders
Browse files Browse the repository at this point in the history
  • Loading branch information
crepererum committed Oct 4, 2023
1 parent b563f1c commit deb3e47
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/commands/list_folders.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashSet;
use std::{collections::HashSet, time::Duration};

use anyhow::{anyhow, ensure, Context, Result};
use thirtyfour::{By, WebDriver, WebElement};
Expand All @@ -7,6 +7,23 @@ use tracing::debug;
use crate::thirtyfour_util::FindExt;

pub async fn list_folders(webdriver: &WebDriver) -> Result<Vec<(WebElement, String)>> {
tokio::time::timeout(Duration::from_secs(20), async {
loop {
let folders = list_folders_inner(webdriver).await?;

if folders.is_empty() {
debug!("folders empty, waiting");
tokio::time::sleep(Duration::from_millis(100)).await;
} else {
return Ok(folders);
}
}
})
.await
.context("no timeout")?
}

async fn list_folders_inner(webdriver: &WebDriver) -> Result<Vec<(WebElement, String)>> {
let folder_column = webdriver
.find_one(By::ClassName("folder-column"))
.await
Expand Down

0 comments on commit deb3e47

Please sign in to comment.