From c978bc85279c597f59379687bb1de07ac3adf539 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Wed, 26 Jun 2024 00:12:22 +0100 Subject: [PATCH 1/3] fix bug where you could enter a file --- src/ui.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index d10a3fb..b242a6c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -175,10 +175,11 @@ impl App { fn right(&mut self) -> Action { if !self.entries.is_empty() { let entry = &self.entries[self.selected]; - Action::GetEntries(Some(entry.path_id)) - } else { - Action::Nothing + if entry.is_dir { + return Action::GetEntries(Some(entry.path_id)); + } } + Action::Nothing } fn move_selection(&mut self, delta: isize, wrap: bool) -> Action { From 4ba070564f06953e04f02ddf8a4dc4ad8a9d5533 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Wed, 26 Jun 2024 00:12:55 +0100 Subject: [PATCH 2/3] remove unnecessary lifetime --- src/cache/mod.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 63e84f0..69e7872 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -284,23 +284,20 @@ pub struct Migrator<'a> { } impl<'a> Migrator<'a> { - pub fn open<'b>(file: &'b Path) -> Result { + pub fn open(file: &Path) -> Result { Self::open_(file, LATEST_VERSION) } #[cfg(any(test, feature = "bench"))] - pub fn open_with_target<'b>( - file: &'b Path, + pub fn open_with_target( + file: &Path, target: VersionId, ) -> Result { Self::open_(file, target) } // We don't try to find multi step migrations. - fn open_<'b>( - file: &'b Path, - target: VersionId, - ) -> Result { + fn open_(file: &Path, target: VersionId) -> Result { let mut conn = Connection::open(file)?; conn.pragma_update(None, "journal_mode", "WAL")?; conn.pragma_update(None, "synchronous", "NORMAL")?; From 3eaacd9c87af4b27b241489226fb043355e2516b Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Wed, 26 Jun 2024 00:13:05 +0100 Subject: [PATCH 3/3] remove unnecessary import --- src/cache/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cache/tests.rs b/src/cache/tests.rs index f747f34..47248af 100644 --- a/src/cache/tests.rs +++ b/src/cache/tests.rs @@ -5,7 +5,7 @@ use rusqlite::Connection; use scopeguard::defer; use uuid::Uuid; -use super::{determine_version, get_tables, LATEST_VERSION, MIGRATIONS}; +use super::{determine_version, get_tables, LATEST_VERSION}; use crate::cache::{ filetree::{InsertError, SizeTree}, Cache, Migrator, VersionId, @@ -383,7 +383,7 @@ fn test_migrate_v0_to_v1() { let marks = ["/foo", "/bar/wat", "foo/a/b/c", "something"]; let file = populate_v0(marks).unwrap(); - let mut cache = + let cache = Migrator::open_with_target(&file, 1).unwrap().migrate().unwrap(); assert_tables(&cache.conn, &[