Browse Source

fix add

db-refactoring
Coin de Gamma 4 months ago
parent
commit
bc4278efe1
  1. 3
      src/main.rs

3
src/main.rs

@ -61,7 +61,7 @@ fn init() -> io::Result<()> {
} }
fn add(id: &String) -> io::Result<()> { fn add(id: &String) -> io::Result<()> {
let db = DB::new(STORAGE_PATH)?; let mut db = DB::new(STORAGE_PATH)?;
if db.items.contains(id) { if db.items.contains(id) {
// TODO: ask to edit existing in outer function which invoked this one // TODO: ask to edit existing in outer function which invoked this one
return Err(io::Error::new( return Err(io::Error::new(
@ -70,6 +70,7 @@ fn add(id: &String) -> io::Result<()> {
)) ))
} }
db.items.insert(id.clone());
db.dump(STORAGE_PATH)?; db.dump(STORAGE_PATH)?;
Ok(()) Ok(())

Loading…
Cancel
Save