From aca38031a4efa3b609769f7f6179181aa378dd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20L=C3=B3pez?= Date: Sat, 11 Jan 2025 22:44:56 +0100 Subject: [PATCH] cli: pass Io without option to get_io(), since even when running in-memory we get a default Io from Clap. Also remove last pesky Io::clone() --- cli/app.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cli/app.rs b/cli/app.rs index 2a05a854f..f114b63a2 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -255,11 +255,10 @@ impl Limbo { .as_ref() .map_or(":memory:".to_string(), |p| p.to_string_lossy().to_string()); - let io_choice = opts.io.clone(); let io = { match db_file.as_str() { - ":memory:" => get_io(DbLocation::Memory, None)?, - _path => get_io(DbLocation::Path, Some(io_choice))?, + ":memory:" => get_io(DbLocation::Memory, opts.io)?, + _path => get_io(DbLocation::Path, opts.io)?, } }; let db = Database::open_file(io.clone(), &db_file)?; @@ -349,8 +348,8 @@ impl Limbo { self.conn.close()?; let io = { match path { - ":memory:" => get_io(DbLocation::Memory, None)?, - _path => get_io(DbLocation::Path, Some(self.opts.io))?, + ":memory:" => get_io(DbLocation::Memory, self.opts.io)?, + _path => get_io(DbLocation::Path, self.opts.io)?, } }; self.io = Arc::clone(&io); @@ -787,14 +786,11 @@ fn get_writer(output: &str) -> Box { } } -fn get_io( - db_location: DbLocation, - io_choice: Option, -) -> anyhow::Result> { +fn get_io(db_location: DbLocation, io_choice: Io) -> anyhow::Result> { Ok(match db_location { DbLocation::Memory => Arc::new(limbo_core::MemoryIO::new()?), DbLocation::Path => { - match io_choice.unwrap() { + match io_choice { Io::Syscall => { // We are building for Linux/macOS and syscall backend has been selected #[cfg(target_family = "unix")]