diff options
author | Teddy Wing | 2021-06-13 19:53:36 +0200 |
---|---|---|
committer | Teddy Wing | 2021-06-13 19:53:36 +0200 |
commit | 0ba3d6e1f6e09c53d938ec03b30be60fee816924 (patch) | |
tree | 1cc65079e599f5e9f0ef81a1a1e9cbd73f583410 /src | |
parent | 321c1725d4866b3177753942abd3073f2d0041a3 (diff) | |
download | reflectub-0ba3d6e1f6e09c53d938ec03b30be60fee816924.tar.bz2 |
run(): Don't clone `base_cgitrc` into each thread
Rejigger some types and signatures to allow us to get references to the
`base_cgitrc` path instead of copying it for each repository.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index b3de5fc..92db74f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -129,7 +129,7 @@ fn run() -> Result<(), MultiError> { &repo, &db, &mirror_root, - base_cgitrc.clone(), // TODO: Can we avoid cloning + base_cgitrc.as_ref(), max_repo_size_bytes, ), ) @@ -153,14 +153,13 @@ fn run() -> Result<(), MultiError> { } /// Mirror or update `repo`. -fn process_repo( +fn process_repo<P: AsRef<Path>>( repo: &github::Repo, db: &database::Db, mirror_root: &str, - base_cgitrc: Option<PathBuf>, + base_cgitrc: Option<P>, max_repo_size_bytes: Option<u64>, ) -> anyhow::Result<()> { - anyhow::bail!("test"); if let Some(max_repo_size_bytes) = max_repo_size_bytes { if is_repo_oversize(repo.size, max_repo_size_bytes) { return Ok(()); @@ -186,9 +185,9 @@ fn process_repo( // database. Err(database::Error::Db(rusqlite::Error::QueryReturnedNoRows)) => { mirror( - &path, + path, &repo, - base_cgitrc.as_ref(), + base_cgitrc, )?; db.repo_insert(db_repo)?; @@ -234,11 +233,15 @@ fn clone_path<P: AsRef<Path>>(base_path: P, repo: &github::Repo) -> PathBuf { } /// Mirror a repository. -fn mirror<P: AsRef<Path>>( - clone_path: P, +fn mirror<P1, P2>( + clone_path: P1, repo: &github::Repo, - base_cgitrc: Option<P>, -) -> anyhow::Result<()> { + base_cgitrc: Option<P2>, +) -> anyhow::Result<()> +where + P1: AsRef<Path>, + P2: AsRef<Path>, +{ git::mirror( &repo.git_url, &clone_path, |