Skip to content

Commit

Permalink
Revert "Properly resolve symlinks"
Browse files Browse the repository at this point in the history
This reverts commit 62e48f7.
  • Loading branch information
bensadeh committed Apr 20, 2024
1 parent e02aa85 commit 3c9ad3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changelog
## 3.1.1


## 3.1.0

- Properly resolve symlinks

## 3.0.1

Expand Down
23 changes: 5 additions & 18 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,17 @@ fn get_output(has_data_from_stdin: bool, is_print_flag: bool, suppress_output: b
}

fn determine_input(path: String) -> Result<Input, Error> {
let canonical_path = fs::canonicalize(&path).map_err(|_| Error {
exit_code: GENERAL_ERROR,
message: format!("{}: No such file or directory", path.red()),
})?;

let canonical_path_str = canonical_path.to_str().ok_or(Error {
exit_code: GENERAL_ERROR,
message: "Canonical path contains invalid UTF-8 characters".into(),
})?;

match check_path_type(&canonical_path)? {
match check_path_type(&path)? {
PathType::File => {
let line_count = count_lines(&canonical_path);
Ok(Input::File(PathAndLineCount {
path: canonical_path_str.to_string(),
line_count,
}))
let line_count = count_lines(&path);
Ok(Input::File(PathAndLineCount { path, line_count }))
}
PathType::Folder => {
let mut paths = list_files_in_directory(&canonical_path)?;
let mut paths = list_files_in_directory(Path::new(&path))?;
paths.sort();

Ok(Input::Folder(FolderInfo {
folder_name: canonical_path_str.to_string(),
folder_name: path,
file_paths: paths,
}))
}
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod types;

use crate::cli::Cli;
use crate::highlight_processor::HighlightProcessor;
use crate::highlighters::Highlighters;
use crate::io::controller::get_io_and_presenter;
use crate::io::presenter::Present;
use crate::io::reader::AsyncLineReader;
Expand Down Expand Up @@ -40,7 +39,7 @@ pub async fn run(theme: Theme, config: Config, cli: Cli) {
let (reached_eof_tx, reached_eof_rx) = oneshot::channel::<()>();
let (io, presenter) = get_io_and_presenter(config, Some(reached_eof_tx)).await;

let highlighter = Highlighters::new(&theme, &cli);
let highlighter = highlighters::Highlighters::new(&theme, &cli);
let highlight_processor = HighlightProcessor::new(highlighter);

tokio::spawn(process_lines(io, highlight_processor));
Expand Down

0 comments on commit 3c9ad3b

Please sign in to comment.