diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 25 | 
1 files changed, 16 insertions, 9 deletions
| diff --git a/src/main.rs b/src/main.rs index 144b578..0977829 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,11 @@ async fn main() {              },              Err(database::Error::Db(sqlx::Error::RowNotFound)) => { -                mirror(&path, &repo, &"./cgitrc".to_owned().into()).unwrap(); +                mirror( +                    &path, +                    &repo, +                    Some(&"./cgitrc".to_owned().into()), +                ).unwrap();                  db.repo_insert(db_repo).await.unwrap();              }, @@ -101,7 +105,7 @@ fn clone_path<P: AsRef<Path>>(base_path: P, repo: &github::Repo) -> PathBuf {  fn mirror<P: AsRef<Path>>(      clone_path: P,      repo: &github::Repo, -    base_cgitrc: P, +    base_cgitrc: Option<P>,  ) -> anyhow::Result<()> {      // mirror database      // update description @@ -114,13 +118,16 @@ fn mirror<P: AsRef<Path>>(      )?;      // Copy the base cgitrc file into the newly-cloned repository. -    let cgitrc_path = clone_path.as_ref().join("cgitrc"); -    fs::copy(&base_cgitrc, &cgitrc_path) -        .with_context(|| format!( -            "unable to copy '{}' to '{}'", -            "./cgitrc", -            &cgitrc_path.display(), -        ))?; +    if let Some(base_cgitrc) = base_cgitrc { +        let cgitrc_path = clone_path.as_ref().join("cgitrc"); + +        fs::copy(&base_cgitrc, &cgitrc_path) +            .with_context(|| format!( +                "unable to copy '{}' to '{}'", +                "./cgitrc", +                &cgitrc_path.display(), +            ))?; +    }      Ok(())  } | 
