|
|
@ -110,7 +110,12 @@ impl Storage { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
pub fn from_db(passphrase: String) -> io::Result<Storage> { |
|
|
|
pub fn from_db(passphrase: String) -> io::Result<Storage> { |
|
|
|
// TODO: throw error if it's not inited
|
|
|
|
if !Storage::is_inited() { |
|
|
|
|
|
|
|
return Err(io::Error::new( |
|
|
|
|
|
|
|
io::ErrorKind::Other, |
|
|
|
|
|
|
|
"Storage is not initialized" |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
} |
|
|
|
let encoder = Encoder::from(passphrase); |
|
|
|
let encoder = Encoder::from(passphrase); |
|
|
|
// TODO: throw error is password is incorrect
|
|
|
|
// TODO: throw error is password is incorrect
|
|
|
|
let file = fs::File::open(&*STORAGE_PATH)?; |
|
|
|
let file = fs::File::open(&*STORAGE_PATH)?; |
|
|
@ -173,8 +178,11 @@ impl Storage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn is_inited() -> bool { |
|
|
|
pub fn is_inited() -> bool { |
|
|
|
|
|
|
|
// TODO: check db
|
|
|
|
|
|
|
|
// TODO check git
|
|
|
|
let path = Path::new(&*STORAGE_FOLDER); |
|
|
|
let path = Path::new(&*STORAGE_FOLDER); |
|
|
|
return path.exists(); |
|
|
|
return path.exists(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn ids(&self) -> Vec<String> { |
|
|
|
pub fn ids(&self) -> Vec<String> { |
|
|
|