Skip to content

Commit

Permalink
fix: clear registry id while init
Browse files Browse the repository at this point in the history
  • Loading branch information
edytapawlak committed Nov 29, 2024
1 parent 953f783 commit 87d304f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
use crate::{
keri::{setup_identifier, KeriError},
subcommands::identifier::IdentifierSubcommandError,
tel::remove_registry,
utils::working_directory,
CliError,
};
Expand Down Expand Up @@ -141,6 +142,7 @@ pub async fn handle_init(
let id = handle_new_id(&keys, kel_config, &db_path).await;
match id {
Ok(id) => {
let _ = remove_registry(&alias);
// Save next keys seed
let mut nsk_path = store_path.clone();
nsk_path.push("next_priv_key");
Expand Down
19 changes: 18 additions & 1 deletion src/tel.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{fs::File, io::Write, sync::Arc};
use std::{
fs::{self, File},
io::Write,
sync::Arc,
};

use keri_controller::{EndRole, IdentifierPrefix, Oobi};
use keri_core::actor::prelude::SelfAddressingIdentifier;
Expand All @@ -21,6 +25,19 @@ pub fn save_registry(alias: &str, registry_id: &str) -> Result<(), CliError> {
Ok(())
}

pub fn remove_registry(alias: &str) -> Result<(), CliError> {
let mut store_path = working_directory()?;
store_path.push(alias);

let mut reg_path = store_path.clone();
reg_path.push("reg_id");

if fs::metadata(&reg_path).is_ok() {
fs::remove_file(reg_path)?;
};
Ok(())
}

pub async fn handle_issue(alias: &str, data: &str) -> Result<(), CliError> {
let mut id = load(alias)?;

Expand Down

0 comments on commit 87d304f

Please sign in to comment.