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]]
name = "xplr"
version = "0.2.15"
version = "0.2.16"
dependencies = [
"anyhow",
"chrono",

@ -1,6 +1,6 @@
[package]
name = "xplr"
version = "0.2.15" # Update app.rs
version = "0.2.16" # Update app.rs
authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018"
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::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";

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

Loading…
Cancel
Save