Browse Source

init++

fix-typo
Coin de Gamma 3 months ago
parent
commit
1b96335853
  1. 29
      src/storage.rs

29
src/storage.rs

@ -143,19 +143,12 @@ impl Storage {
}
pub fn init(passphrase: String) -> io::Result<()> {
// TODO: revrite all logic
// Check if the folder exists and is a directory
//if path.exists() && path.is_dir() {
// Err(io::Error::new(io::ErrorKind::NotFound, "Folder does not exist"))
//}
//fs::File::create(&*STORAGE_PATH)?;
//let st = Storage::new(passphrase);
//st.dump()?;
//println!("Storage db created.");
//println!("Initialization complete.");
//println!("");
//println!("Now it's required to add folder `{}` under git manually.", &*STORAGE_FOLDER);
//println!("Don't worry it's going to be encrypted.");
Storage::check_installed()?;
let db_path = Storage::get_db_path()?;
fs::File::create(db_path)?;
let st = Storage::new(passphrase);
st.dump()?;
println!("Storage db created");
Ok(())
}
@ -169,10 +162,14 @@ impl Storage {
format!("{} does not exist or not a dir", Storage::get_storage_path()?)
));
}
let git_path = storage_path.join(".git");
if !git_path.exists() || !git_path.is_dir() {
return Err(io::Error::new(
io::ErrorKind::NotFound,
format!("{} not under git", Storage::get_storage_path()?)
));
}
Ok(())
// TODO check git
}
pub fn is_inited() -> io::Result<bool> {

Loading…
Cancel
Save