From e389617207dffc2010862bf6dabea1576789e720 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 8 Sep 2023 17:18:16 +0000 Subject: [PATCH] Whitespace --- src/db.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/db.rs b/src/db.rs index 82e5d93..0390c0d 100644 --- a/src/db.rs +++ b/src/db.rs @@ -54,7 +54,7 @@ pub struct Meta { pub fn open(path: PathBuf) -> Result { debug!("DB: Opening file: {:?}", path); let mut conn = Connection::open_with_flags(path, OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE) - .context("Problem opening file")?; + .context("Problem opening file")?; conn.pragma_update(None, "foreign_keys", "ON") .context("Problem enabling SQLite foreign_keys pragma")?; @@ -64,7 +64,7 @@ pub fn open(path: PathBuf) -> Result { rusqlite::vtab::array::load_module(&conn) .context("Problem enabling array module")?; - + Ok(conn) } @@ -151,7 +151,7 @@ pub fn set_item_tags(conn: &Connection, item: Item, tags: &Vec) -> Resul name: tag_name.to_string() })?; } - + Ok(()) } @@ -163,7 +163,7 @@ pub fn query_all_items(conn: &Connection) -> Result> { .context("Problem preparing SQL statement")?; let mut rows = statement.query([])?; let mut items = Vec::new(); - + while let Some(row) = rows.next()? { let item = Item { id: row.get(0)?, @@ -173,7 +173,7 @@ pub fn query_all_items(conn: &Connection) -> Result> { }; items.push(item); } - + Ok(items) } @@ -213,7 +213,7 @@ pub fn query_tagged_items<'a>(conn: &'a Connection, tags: &'a Vec) -> Re }; items.push(item); } - + Ok(items) } @@ -232,7 +232,7 @@ pub fn get_items_matching(conn: &Connection, tags: &Vec, meta: &HashMap< true => query_all_items(conn)?, false => query_tagged_items(conn, tags)? }; - + if meta.is_empty() { debug!("DB: Not filtering on meta"); Ok(items) @@ -245,15 +245,15 @@ pub fn get_items_matching(conn: &Connection, tags: &Vec, meta: &HashMap< for meta in get_item_meta(conn, item)? { item_meta.insert(meta.name, meta.value); } - + debug!("DB: Matching: {:?}: {:?}", item, item_meta); - + for (k, v) in meta.iter() { match item_meta.get(k) { Some(value) => item_ok = v.eq(value), None => item_ok = false } - + if item_ok { break; } @@ -265,7 +265,7 @@ pub fn get_items_matching(conn: &Connection, tags: &Vec, meta: &HashMap< } Ok(filtered_items) } - + } @@ -291,11 +291,11 @@ pub fn get_item_matching(conn: &Connection, tags: &Vec, _meta: &HashMap< .iter() .map(|s| {rusqlite::types::Value::from(s.clone()) }) .collect(); - + let tags_ptr = Rc::new(tags_values); - + let mut rows = statement.query((&tags_ptr, &tags.len()))?; - + match rows.next()? { Some(row) => Ok(Some(Item { id: row.get(0)?, @@ -318,7 +318,7 @@ pub fn get_item(conn: &Connection, item_id: i64) -> Result> { .context("Problem preparing SQL statement")?; let mut rows = statement.query([item_id])?; - + match rows.next()? { Some(row) => Ok(Some(Item { id: row.get(0)?, @@ -361,7 +361,7 @@ pub fn get_item_tags(conn: &Connection, item: &Item) -> Result> { let mut rows = statement.query([item.id])?; let mut tags = Vec::new(); - + while let Some(row) = rows.next()? { tags.push(Tag { id: row.get(0)?, @@ -381,7 +381,7 @@ pub fn get_item_meta(conn: &Connection, item: &Item) -> Result> { let mut rows = statement.query([item.id])?; let mut metas = Vec::new(); - + while let Some(row) = rows.next()? { metas.push(Meta { id: row.get(0)?,