Merge pull request #1255 from matthiasbeyer/imag-notes/fix-list

Fix imag-notes list errors
This commit is contained in:
Matthias Beyer 2018-02-06 21:45:37 +01:00 committed by GitHub
commit 1b588172dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 16 deletions

View File

@ -29,3 +29,4 @@ libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror"
libimagnotes = { version = "0.6.0", path = "../../../lib/domain/libimagnotes" }
libimagentryedit = { version = "0.6.0", path = "../../../lib/entry/libimagentryedit" }
libimagutil = { version = "0.6.0", path = "../../../lib/etc/libimagutil" }
libimagstore = { version = "0.6.0", path = "../../../lib/core/libimagstore" }

View File

@ -26,15 +26,21 @@ extern crate libimagrt;
extern crate libimagentryedit;
extern crate libimagerror;
extern crate libimagutil;
extern crate libimagstore;
use std::process::exit;
use itertools::Itertools;
use libimagentryedit::edit::Edit;
use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup;
use libimagstore::iter::get::StoreIdGetIteratorExtension;
use libimagnotes::note::Note;
use libimagnotes::notestore::*;
use libimagerror::trace::MapErrTrace;
use libimagerror::trace::trace_error_exit;
use libimagerror::iter::TraceIterator;
use libimagutil::info_result::*;
use libimagutil::warn_result::WarnResult;
@ -114,7 +120,12 @@ fn list(rt: &Runtime) {
.store()
.all_notes()
.map_err_trace_exit_unwrap(1)
.filter_map(|noteid| rt.store().get(noteid).map_err_trace_exit_unwrap(1))
.into_get_iter(rt.store())
.unwrap_with(|e| trace_error_exit(&e, 1))
.map(|opt| opt.unwrap_or_else(|| {
error!("Fatal: Nonexistent entry where entry should exist");
exit(1)
}))
.sorted_by(|note_a, note_b| if let (Ok(a), Ok(b)) = (note_a.get_name(), note_b.get_name()) {
return a.cmp(&b)
} else {

View File

@ -22,6 +22,10 @@ error_chain! {
NoteError, NoteErrorKind, ResultExt, Result;
}
foreign_links {
TomlQueryError(::toml_query::error::Error);
}
errors {
StoreWriteError {
description("Error writing store")

View File

@ -17,15 +17,13 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
use std::collections::BTreeMap;
use toml::Value;
use libimagstore::storeid::IntoStoreId;
use libimagstore::store::FileLockEntry;
use libimagstore::store::Store;
use toml_query::set::TomlValueSetExt;
use toml_query::insert::TomlValueInsertExt;
use module_path::ModuleEntryPath;
use error::Result;
@ -56,18 +54,7 @@ impl<'a> NoteStore<'a> for Store {
{
let entry = lockentry.deref_mut();
{
let header = entry.get_header_mut();
let _ = header
.set("note", Value::Table(BTreeMap::new()))
.chain_err(|| NEK::StoreWriteError);
let _ = header
.set("note.name", Value::String(name))
.chain_err(|| NEK::StoreWriteError);
}
entry.get_header_mut().insert("note.name", Value::String(name))?;
*entry.get_content_mut() = text;
}