Skip to content

Commit

Permalink
Merge pull request #32 from drdo/fix-bug
Browse files Browse the repository at this point in the history
Fix bug where you could enter a file
  • Loading branch information
drdo authored Jun 26, 2024
2 parents aaf5bc6 + 3eaacd9 commit 7d9d8a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
11 changes: 4 additions & 7 deletions src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,20 @@ pub struct Migrator<'a> {
}

impl<'a> Migrator<'a> {
pub fn open<'b>(file: &'b Path) -> Result<Self, MigrationError> {
pub fn open(file: &Path) -> Result<Self, MigrationError> {
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, MigrationError> {
Self::open_(file, target)
}

// We don't try to find multi step migrations.
fn open_<'b>(
file: &'b Path,
target: VersionId,
) -> Result<Self, MigrationError> {
fn open_(file: &Path, target: VersionId) -> Result<Self, MigrationError> {
let mut conn = Connection::open(file)?;
conn.pragma_update(None, "journal_mode", "WAL")?;
conn.pragma_update(None, "synchronous", "NORMAL")?;
Expand Down
4 changes: 2 additions & 2 deletions src/cache/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, &[
Expand Down
7 changes: 4 additions & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7d9d8a9

Please sign in to comment.