diff --git a/src/upgrades/v0_9_0/ca_objects_migration.rs b/src/upgrades/v0_9_0/ca_objects_migration.rs index efeee69d..de128168 100644 --- a/src/upgrades/v0_9_0/ca_objects_migration.rs +++ b/src/upgrades/v0_9_0/ca_objects_migration.rs @@ -72,16 +72,6 @@ impl CaObjectsMigration { info!("Populate the CA Objects Store introduced in Krill 0.9.0"); let store = AggregateStore::::disk(&config.data_dir, CASERVER_DIR)?; - // for ca in - - // if store.warm().is_err() { - // // most likely we are dealing with off by one errors in old krill info files. Archive them for migration and try again. - // for c in store.list()? { - // let info_key = KeyStoreKey::scoped(c.to_string(), "info.json".to_string()); - // kv.drop_key(&info_key)?; - // } - // } - let ca_objects_store = CaObjectsStore::disk(&config.upgrade_data_dir(), config.issuance_timing.clone(), signer)?; diff --git a/src/upgrades/v0_9_0/pubd_objects_migration.rs b/src/upgrades/v0_9_0/pubd_objects_migration.rs index de66ff8a..9fa82315 100644 --- a/src/upgrades/v0_9_0/pubd_objects_migration.rs +++ b/src/upgrades/v0_9_0/pubd_objects_migration.rs @@ -75,16 +75,29 @@ impl PubdObjectsMigration { fn populate_repo_content(config: Arc) -> UpgradeResult<()> { info!("Populate the repository content based on current state"); let old_store = AggregateStore::::disk(&config.data_dir, PUBSERVER_DIR)?; - if old_store.warm().is_err() { - // This is most likely because the info last event is off by one which affected - // some old version. Try archiving the info.json to force that the publication - // server is rebuilt from scratch. - let kv = KeyValueStore::disk(&config.data_dir, PUBSERVER_DIR)?; - let info = KeyStoreKey::scoped("0".to_string(), "info.json".to_string()); - kv.archive_to(&info, "archived")?; - } - let old_repo = old_store.get_latest(&Self::repository_handle())?; + let repo_handle = Self::repository_handle(); + + let old_repo = match old_store.get_latest(&repo_handle) { + Ok(repo) => repo, + Err(_) => { + // most likely an off by one error in the info.json of early releases + // try to move the info file out of the way and reload. + let kv = KeyValueStore::disk(&config.data_dir, PUBSERVER_DIR)?; + let info_key = KeyStoreKey::scoped(repo_handle.to_string(), "info.json".to_string()); + let tmp_key = KeyStoreKey::scoped(repo_handle.to_string(), "tmp-info.json".to_string()); + kv.move_key(&info_key, &tmp_key)?; + + // Get latest (may still error) + let res = old_store.get_latest(&repo_handle); + + // move the key back to leave things as they were + kv.move_key(&tmp_key, &info_key)?; + + // Get the repo or error out if this failed. + res? + } + }; let publishers = old_repo .publishers