message: Cleanup inserting owners into database
diff: @@ -349,8 +349,7 @@ fn update_owners_in_database(
  owners: &[CrateOwner],
  crate_id: i32,
  ) -> Result<()> {
  - let existing_owners: Vec<String> = conn
  - .query(
  + let rows = conn.query(
  "
  SELECT login
  FROM owners
  @@ -359,10 +358,8 @@ fn update_owners_in_database(
  WHERE owner_rels.cid = $1
  ",
  &[&crate_id],
  - )?
  - .into_iter()
  - .map(|row| row.get(0))
  - .collect();
  + )?;
  + let existing_owners = rows.into_iter().map(|row| -> String { row.get(0) });
  for owner in owners {
  debug!("Updating owner data for {}: {:?}", owner.login, owner);
  @@ -388,26 +385,14 @@ fn update_owners_in_database(
  };
  // add relationship
  - let updated = conn.query(
  - "INSERT INTO owner_rels (cid, oid) VALUES ($1, $2)",
  + conn.query(
  + "INSERT INTO owner_rels (cid, oid) VALUES ($1, $2) ON CONFLICT DO NOTHING",
  &[&crate_id, &owner_id],
  - );
  -
  - match updated {
  - Ok(_) => debug!("Added new owner relationship"),
  - Err(e)
  - if e.as_db().and_then(|e| e.constraint.as_deref())
  - == Some("owner_rels_cid_oid_key") =>
  - {
  - debug!("Existing owner relationship");
  - }
  - Err(e) => return Err(e.into()),
  - }
  + )?;
  }
  - let to_remove = existing_owners
  - .iter()
  - .filter(|login| !owners.iter().any(|owner| &&owner.login == login));
  + let to_remove =
  + existing_owners.filter(|login| !owners.iter().any(|owner| &owner.login == login));
  for login in to_remove {
  debug!("Removing owner relationship {}", login);
  