Log explorer errors

pull/3/head
Arijit Basu 3 years ago
parent e93e815bc4
commit 4d2caf512e
No known key found for this signature in database
GPG Key ID: 7D7BF809E7378863

2
Cargo.lock generated

@ -1671,7 +1671,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "xplr" name = "xplr"
version = "0.2.15" version = "0.2.16"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",

@ -1,6 +1,6 @@
[package] [package]
name = "xplr" name = "xplr"
version = "0.2.15" # Update app.rs version = "0.2.16" # Update app.rs
authors = ["Arijit Basu <sayanarijit@gmail.com>"] authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018" edition = "2018"
description = "A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf" description = "A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf"

@ -14,7 +14,7 @@ use std::fs;
use std::io; use std::io;
use std::path::PathBuf; use std::path::PathBuf;
pub const VERSION: &str = "v0.2.15"; // Update Cargo.toml pub const VERSION: &str = "v0.2.16"; // Update Cargo.toml
pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW"; pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW";

@ -1,8 +1,4 @@
use crate::app::DirectoryBuffer; use crate::app::{DirectoryBuffer, ExplorerConfig, ExternalMsg, InternalMsg, MsgIn, Node, Task};
use crate::app::ExplorerConfig;
use crate::app::Node;
use crate::app::Task;
use crate::app::{InternalMsg, MsgIn};
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
@ -20,9 +16,9 @@ pub fn explore(
let config_cloned = config.clone(); let config_cloned = config.clone();
thread::spawn(move || { thread::spawn(move || {
let nodes: Vec<Node> = fs::read_dir(&path) fs::read_dir(&path)
.unwrap() .map(|dirs| {
.filter_map(|d| { dirs.filter_map(|d| {
d.ok().map(|e| { d.ok().map(|e| {
e.path() e.path()
.file_name() .file_name()
@ -32,8 +28,9 @@ pub fn explore(
}) })
.map(|name| Node::new(parent.clone(), name)) .map(|name| Node::new(parent.clone(), name))
.filter(|n| config.apply(n)) .filter(|n| config.apply(n))
.collect(); .collect::<Vec<Node>>()
})
.map(|nodes| {
let focus_index = if let Some(focus) = focused_path { let focus_index = if let Some(focus) = focused_path {
nodes nodes
.iter() .iter()
@ -53,6 +50,15 @@ pub fn explore(
None, None,
)) ))
.unwrap(); .unwrap();
})
.unwrap_or_else(|e| {
tx.send(Task::new(
1,
MsgIn::External(ExternalMsg::LogError(e.to_string())),
None,
))
.unwrap();
})
}); });
if let Some(grand_parent) = path_cloned.parent() { if let Some(grand_parent) = path_cloned.parent() {

Loading…
Cancel
Save