Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dir_exists sometimes returns FALSE for a relative symlink to a directory #395

Open
heavywatal opened this issue Sep 18, 2022 · 4 comments · May be fixed by #397
Open

dir_exists sometimes returns FALSE for a relative symlink to a directory #395

heavywatal opened this issue Sep 18, 2022 · 4 comments · May be fixed by #397
Labels
bug an unexpected problem or unintended behavior

Comments

@heavywatal
Copy link
Contributor

It is not always, but under some unknown conditions:

x = fs::dir_create(tempfile())
parent = fs::path_dir(x)

abs_ln = fs::link_create(x, fs::path(parent, "abs_ln"))
fs::link_exists(abs_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/abs_ln 
#>                                                               TRUE
fs::dir_exists(abs_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/abs_ln 
#>                                                               TRUE

rel_ln = fs::link_create(fs::path_file(x), fs::path(parent, "rel_ln"))
fs::link_exists(rel_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/rel_ln 
#>                                                               TRUE
fs::dir_exists(rel_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/rel_ln 
#>                                                              FALSE

setwd(parent)
fs::dir_create("path")
rel_ln2 = fs::link_create("path", "new_path")
fs::link_exists("new_path")
#> new_path 
#>     TRUE
fs::dir_exists("new_path")
#> new_path 
#>     TRUE

cat(system2("lsd", c("--tree", parent), stdout = TRUE), sep = "\n")
#> RtmpLxUH0e/
#> ├── abs_ln@ ⇒ /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/file772215100b6f
#> ├── file772215100b6f/
#> ├── new_path@ ⇒ path
#> ├── path/
#> └── rel_ln@ ⇒ file772215100b6f

Created on 2022-09-18 with reprex v2.0.2

  • fs 1.5.2
  • R version 4.2.1 (2022-06-23)
  • Platform: x86_64-apple-darwin17.0 (64-bit); macOS 12.5.1
  • Platform: x86_64-pc-linux-gnu (64-bit): Ubuntu 20.04.5
@heavywatal
Copy link
Contributor Author

I guess the following part needs a fix similar to #280:

fs/R/access.R

Line 47 in 238032f

res[links] <- is_dir(link_path(path[links]))

@gaborcsardi

This comment was marked as off-topic.

@heavywatal

This comment was marked as off-topic.

@gaborcsardi

This comment was marked as off-topic.

heavywatal added a commit to heavywatal/fs that referenced this issue Sep 20, 2022
@heavywatal heavywatal linked a pull request Sep 20, 2022 that will close this issue
@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants