hagridctl: adapt regenerate script to only regenerate verified keys
This commit is contained in:
parent
a2f36a5e55
commit
85ca188ffb
|
@ -236,7 +236,7 @@ impl Filesystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the backing primary key fingerprint for any key path.
|
/// Returns the backing primary key fingerprint for any key path.
|
||||||
fn path_to_primary(path: &Path) -> Option<Fingerprint> {
|
pub fn path_to_primary(path: &Path) -> Option<Fingerprint> {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
let typ = fs::symlink_metadata(&path).ok()?.file_type();
|
let typ = fs::symlink_metadata(&path).ok()?.file_type();
|
||||||
if typ.is_symlink() {
|
if typ.is_symlink() {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
use failure;
|
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
@ -80,7 +79,7 @@ pub fn do_regenerate(config: &HagridConfig) -> Result<()> {
|
||||||
false,
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let published_dir = config.keys_external_dir.as_ref().unwrap().join("pub");
|
let published_dir = config.keys_external_dir.as_ref().unwrap().join("links").join("by-email");
|
||||||
let dirs: Vec<_> = WalkDir::new(published_dir)
|
let dirs: Vec<_> = WalkDir::new(published_dir)
|
||||||
.min_depth(1)
|
.min_depth(1)
|
||||||
.max_depth(1)
|
.max_depth(1)
|
||||||
|
@ -109,13 +108,13 @@ pub fn do_regenerate(config: &HagridConfig) -> Result<()> {
|
||||||
|
|
||||||
fn regenerate_dir_recursively(db: &KeyDatabase, stats: &mut RegenerateStats, dir: &Path) -> Result<()> {
|
fn regenerate_dir_recursively(db: &KeyDatabase, stats: &mut RegenerateStats, dir: &Path) -> Result<()> {
|
||||||
for path in WalkDir::new(dir)
|
for path in WalkDir::new(dir)
|
||||||
|
.follow_links(true)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.filter(|e| e.file_type().is_file())
|
.filter(|e| e.file_type().is_file())
|
||||||
.map(|entry| entry.into_path()) {
|
.map(|entry| entry.into_path()) {
|
||||||
|
|
||||||
let fpr = KeyDatabase::path_to_fingerprint(&path)
|
let fpr = KeyDatabase::path_to_primary(&path).unwrap();
|
||||||
.ok_or_else(|| failure::err_msg("Key not in database!"))?;
|
|
||||||
let result = db.regenerate_links(&fpr);
|
let result = db.regenerate_links(&fpr);
|
||||||
stats.update(result, fpr);
|
stats.update(result, fpr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue