Remove duplicate code, clippy fixes
This commit is contained in:
parent
95107b6a39
commit
0fcf8fe523
3 changed files with 6 additions and 8 deletions
|
@ -38,7 +38,7 @@ pub async fn crawl(
|
|||
Err(e) => {
|
||||
failed_instances += 1;
|
||||
eprintln!("Failed to crawl {}: {}", current_instance.domain, e)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ async fn fetch_instance_details(domain: &str) -> Result<InstanceDetails, Error>
|
|||
let linked_instances = site_info
|
||||
.federated_instances
|
||||
.map(|f| f.linked)
|
||||
.unwrap_or(vec![]);
|
||||
.unwrap_or_default();
|
||||
Ok(InstanceDetails {
|
||||
domain: domain.to_owned(),
|
||||
name: site_info.site_view.site.name,
|
||||
|
|
|
@ -5,5 +5,5 @@ pub mod federated_instances;
|
|||
pub mod node_info;
|
||||
|
||||
pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
pub const DEFAULT_START_INSTANCES: &'static str = "lemmy.ml";
|
||||
pub const DEFAULT_MAX_CRAWL_DEPTH: &'static str = "1";
|
||||
pub const DEFAULT_START_INSTANCES: &str = "lemmy.ml";
|
||||
pub const DEFAULT_MAX_CRAWL_DEPTH: &str = "1";
|
||||
|
|
|
@ -18,10 +18,10 @@ pub async fn main() -> Result<(), Error> {
|
|||
.takes_value(true),
|
||||
)
|
||||
.get_matches();
|
||||
let trusted_instances: Vec<String> = matches
|
||||
let start_instances: Vec<String> = matches
|
||||
.value_of("start-instances")
|
||||
.unwrap_or(DEFAULT_START_INSTANCES)
|
||||
.split(",")
|
||||
.split(',')
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
let max_crawl_depth: i32 = matches
|
||||
|
@ -29,8 +29,6 @@ pub async fn main() -> Result<(), Error> {
|
|||
.unwrap_or(DEFAULT_MAX_CRAWL_DEPTH)
|
||||
.parse()?;
|
||||
|
||||
let start_instances = trusted_instances.iter().map(|s| s.to_string()).collect();
|
||||
|
||||
eprintln!("Crawling...");
|
||||
let (instance_details, failed_instances) = crawl(start_instances, max_crawl_depth).await?;
|
||||
let total_stats = aggregate(instance_details, failed_instances);
|
||||
|
|
Loading…
Reference in a new issue