From 52cf0f1b91e76d32c0f121d49cf8d4a9836d48b9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 5 Jun 2021 14:19:34 +0200 Subject: run(): Move comment --- src/main.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index e487ec4..c736603 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,19 +94,14 @@ async fn run() -> anyhow::Result<()> { db.create().await?; - // If repo !exists - // insert - // mirror - // Else - // Update updated_at - // fetch - for repo in test_repos { let id = repo.id; let path = clone_path(&mirror_root, &repo); let db_repo = database::Repo::from(&repo); match db.repo_get(id).await { + // If we've already seen the repo and it's been updated, fetch the + // latest. Ok(current_repo) => { if db.repo_is_updated(&db_repo).await? { update(&path, ¤t_repo, &repo)?; @@ -115,6 +110,8 @@ async fn run() -> anyhow::Result<()> { } }, + // If the repo doesn't exist, mirror it and store it in the + // database. Err(database::Error::Db(sqlx::Error::RowNotFound)) => { mirror( &path, -- cgit v1.2.3