exa icon indicating copy to clipboard operation
exa copied to clipboard

Try canonicalisation when converting File to Dir

Open Frederick888 opened this issue 2 years ago • 1 comments

Without this canonicalisation, if the directory is a symbolic link to another directory, later at reorient_target_path [1], File and path argument look like:

- self: File {
    name: "."
    ext: None
    path: "/tmp/test2"
    metadata: {...}
    parent_dir: Some({
      contents: vec![]
      path: "/tmp/test2"
    })
    is_all_all: true
  }
- path: "test1"

...where /tmp/test2 is a symlink to /tmp/test1 and command being used is exa -laa /tmp/test2.

So the result of dir.join(&*path) becomes /tmp/test2/test1, which doesn't exist.

The canonicalisation also makes the behaviours of exa -laa /tmp/test2 and exa -laa /tmp/test2/ consistent, where . is not treated as a symlink in either case. This is a bit different from coreutils ls though.

Closes #952.

[1] https://github.com/ogham/exa/blob/42659f93456d9ff7cc1096cbd84d778ede26d76e/src/fs/file.rs#L215-L217

Frederick888 avatar Jan 29 '22 15:01 Frederick888

I have changed the code quite a bit in #872, do you think the two could work together? Also, I think it would be nice to have a test with vagrant (look at the README), do you think you could look at it? Since symlinks are tricky, I think it would be nice to have tests (and check they passes, since they aren’t run on the CI).

ariasuni avatar Mar 17 '22 18:03 ariasuni