Skip to content

Commit

Permalink
assure device_id is taken from the final CWD (#186) (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 6, 2023
1 parent e9fb2fd commit 74e6d42
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() -> Result<()> {
let res = TerminalApp::initialize(
&mut terminal,
walk_options,
paths_from(input, !opt.stay_on_filesystem)?,
extract_paths_maybe_set_cwd(input, !opt.stay_on_filesystem)?,
Interaction::Full,
)?
.map(|(keys_rx, mut app)| {
Expand Down Expand Up @@ -101,7 +101,7 @@ fn main() -> Result<()> {
walk_options,
!no_total,
!no_sort,
paths_from(input, !opt.stay_on_filesystem)?,
extract_paths_maybe_set_cwd(input, !opt.stay_on_filesystem)?,
)?;
if statistics {
writeln!(io::stderr(), "{:?}", stats).ok();
Expand All @@ -117,7 +117,7 @@ fn main() -> Result<()> {
walk_options,
true,
true,
paths_from(opt.input, !opt.stay_on_filesystem)?,
extract_paths_maybe_set_cwd(opt.input, !opt.stay_on_filesystem)?,
)?
.0
}
Expand All @@ -126,15 +126,17 @@ fn main() -> Result<()> {
process::exit(res.to_exit_code());
}

fn paths_from(mut paths: Vec<PathBuf>, cross_filesystems: bool) -> Result<Vec<PathBuf>, io::Error> {
let device_id = std::env::current_dir()
.ok()
.and_then(|cwd| crossdev::init(&cwd).ok());

fn extract_paths_maybe_set_cwd(
mut paths: Vec<PathBuf>,
cross_filesystems: bool,
) -> Result<Vec<PathBuf>, io::Error> {
if paths.len() == 1 {
std::env::set_current_dir(&paths[0])?;
paths.remove(0);
paths.clear();
}
let device_id = std::env::current_dir()
.ok()
.and_then(|cwd| crossdev::init(&cwd).ok());

if paths.is_empty() {
cwd_dirlist().map(|paths| match device_id {
Expand Down

0 comments on commit 74e6d42

Please sign in to comment.