Let save_self_keypair() also remove a previously used key

The imex code was deleting the key if it was already used.  Turns out
none of the callers would not want this behaviour, so let's just
handle this case generally.
This commit is contained in:
Floris Bruynooghe
2020-02-06 00:52:50 +01:00
committed by Floris Bruynooghe
parent 5c3a8819a4
commit 81ff5d1224
2 changed files with 59 additions and 35 deletions

View File

@@ -315,13 +315,6 @@ fn set_self_key(
ensure!(self_addr.is_some(), "Missing self addr");
let addr = EmailAddress::new(&self_addr.unwrap_or_default())?;
// XXX maybe better make dc_key_save_self_keypair delete things
sql::execute(
context,
&context.sql,
"DELETE FROM keypairs WHERE public_key=? OR private_key=?;",
params![public_key.to_bytes(), private_key.to_bytes()],
)?;
let (public, secret) = match (public_key, private_key) {
(Key::Public(p), Key::Secret(s)) => (p, s),
_ => bail!("wrong keys unpacked"),