Branch: Tag:

2017-11-03

2017-11-03 11:12:18 by Henrik Grubbström (Grubba) <grubba@grubba.org>

CertDB: Update the PEM file metadata.

130:    }    }    -  // Mark the old certs and keys as no longer in the PEM file. +  if (!raw_pem) { +  // Mark any old certs and keys as stale.    db->query("UPDATE certs "    " SET pem_id = NULL, "    " msg_no = NULL "
141:    " msg_no = NULL "    " WHERE pem_id = %d",    pem_id); +  return; +  }    -  if (!raw_pem) return; +  // Mark any old certs and keys as update in progress. +  db->query("UPDATE certs " +  " SET msg_no = NULL " +  " WHERE pem_id = %d", +  pem_id); +  db->query("UPDATE cert_keys " +  " SET msg_no = NULL " +  " WHERE pem_id = %d", +  pem_id);       mixed err =    catch {
352:    tmp[0]->id);    }    } +  +  // Mark any old certs and keys that are still update in progress as stale. +  db->query("UPDATE certs " +  " SET pem_id = NULL " +  " WHERE pem_id = %d " +  " AND msg_no IS NULL", +  pem_id); +  db->query("UPDATE cert_keys " +  " SET pem_id = NULL " +  " WHERE pem_id = %d " +  " AND msg_no IS NULL", +  pem_id); +  +  // Update metadata about the imported PEM file. +  db->query("UPDATE cert_pem_files " +  " SET hash = %s, " +  " mtime = %d, " +  " itime = %d " +  " WHERE id = %d", +  pem_hash, st->mtime, time(1), +  pem_id);   }      void refresh_pem(int pem_id)