|
|
@ -143,19 +143,12 @@ impl Storage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn init(passphrase: String) -> io::Result<()> { |
|
|
|
pub fn init(passphrase: String) -> io::Result<()> { |
|
|
|
// TODO: revrite all logic
|
|
|
|
Storage::check_installed()?; |
|
|
|
// Check if the folder exists and is a directory
|
|
|
|
let db_path = Storage::get_db_path()?; |
|
|
|
//if path.exists() && path.is_dir() {
|
|
|
|
fs::File::create(db_path)?; |
|
|
|
// Err(io::Error::new(io::ErrorKind::NotFound, "Folder does not exist"))
|
|
|
|
let st = Storage::new(passphrase); |
|
|
|
//}
|
|
|
|
st.dump()?; |
|
|
|
//fs::File::create(&*STORAGE_PATH)?;
|
|
|
|
println!("Storage db created"); |
|
|
|
//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.");
|
|
|
|
|
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -169,10 +162,14 @@ impl Storage { |
|
|
|
format!("{} does not exist or not a dir", Storage::get_storage_path()?) |
|
|
|
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(()) |
|
|
|
Ok(()) |
|
|
|
|
|
|
|
|
|
|
|
// TODO check git
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn is_inited() -> io::Result<bool> { |
|
|
|
pub fn is_inited() -> io::Result<bool> { |
|
|
|