aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-05-30 18:10:00 +0200
committerTeddy Wing2021-05-30 18:10:00 +0200
commit850b2aadd402ab80c0d2c371fe7be3066271a1ab (patch)
treec3d5965a1887351d95401a792c2c333d33d35ec0 /src/main.rs
parentb7c396b9db42f60d091755eed547c295edd970ac (diff)
downloadreflectub-850b2aadd402ab80c0d2c371fe7be3066271a1ab.tar.bz2
Only update repository description if the description changed
Check the repository description that comes back from the GitHub API against our cached description in the database. Only write the new description if it changed so we can avoid writing to the file in that case.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 2a3e988..697ca7e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -62,9 +62,9 @@ async fn main() {
let db_repo = database::Repo::from(&repo);
match db.repo_get(id).await {
- Ok(_) => {
+ Ok(current_repo) => {
if db.repo_is_updated(&db_repo).await.unwrap() {
- update(&path, &repo).unwrap();
+ update(&path, &current_repo, &repo).unwrap();
db.repo_update(&db_repo).await.unwrap();
}
@@ -116,12 +116,16 @@ fn mirror<P: AsRef<Path>>(
fn update<P: AsRef<Path>>(
repo_path: P,
- repo: &github::Repo,
+ current_repo: &database::Repo,
+ updated_repo: &github::Repo,
) -> anyhow::Result<()> {
git::update(&repo_path)?;
- // TODO: Don't write if description is the same
- git::update_description(&repo_path, repo.description())?;
+ let remote_description = updated_repo.description();
+
+ if current_repo.description() != remote_description {
+ git::update_description(&repo_path, remote_description)?;
+ }
Ok(())
}