diff --git a/src/main.rs b/src/main.rs index efdb8a2..adab21e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,20 @@ #![feature(let_chains)] +use std::path::Path; use std::process::Command; use std::sync::mpsc; -use std::path::Path; -use std::sync::{Mutex, Arc, atomic::{AtomicUsize, Ordering}}; +use std::sync::{ + Arc, Mutex, + atomic::{AtomicUsize, Ordering}, +}; +use clap::Parser; use log::{debug, trace}; use serde::{Deserialize, Serialize}; use serde_json; use tokio::sync::Semaphore; -use clap::Parser; -const UPSTREAM_CACHES: &'static [&'static str] = &[ - "https://cache.nixos.org", -]; +const UPSTREAM_CACHES: &'static [&'static str] = &["https://cache.nixos.org"]; // nix path-info --derivation --json #[derive(Debug, Serialize, Deserialize)] @@ -112,7 +113,13 @@ async fn main() { println!("spawning check_upstream"); handles.push(tokio::spawn(async move { - check_upstream(store_paths, cacheable_tx, cli.upstream_checker_concurrency, upstream_caches).await; + check_upstream( + store_paths, + cacheable_tx, + cli.upstream_checker_concurrency, + upstream_caches, + ) + .await; })); println!("spawning uploader"); @@ -127,7 +134,12 @@ async fn main() { } // filter out store paths that exist in upstream caches -async fn check_upstream(store_paths: Vec, cacheable_tx: mpsc::Sender, concurrency: u8, upstream_caches: Vec) { +async fn check_upstream( + store_paths: Vec, + cacheable_tx: mpsc::Sender, + concurrency: u8, + upstream_caches: Vec, +) { let concurrent = Semaphore::new(concurrency.into()); for store_path in store_paths { let _ = concurrent.acquire().await.unwrap(); @@ -152,7 +164,9 @@ async fn check_upstream(store_paths: Vec, cacheable_tx: mpsc::Sender, binary_cache: String, co handle.await.unwrap(); } println!("uploaded {} paths", upload_count.load(Ordering::Relaxed)); - + let failures = failures.lock().unwrap(); if !failures.is_empty() { println!("failed to upload these paths: ");