fs
fs copied to clipboard
file_info does not fail or warn when file is missing
I read in the docs that file_info and file_size will fail if the file does not exist (or give a warning if fail=FALSE). However, it seems that the call does not fail, and instead returns NA. This is the same behavior as file.size.
Reprex:
library(fs)
file_size("this-file-does-not-exist", fail=TRUE)
#> NA
file_size("this-file-does-not-exist", fail=FALSE)
#> NA
I think this behavior is the function working as expected, at least according to the test below, but it does seem like the docs are out of date. https://github.com/r-lib/fs/blob/4cc4b56c26b9d7f177a676fbb331133bb2584b86/tests/testthat/test-file.R#L18-L25
This seems to be a bug, if fail = TRUE file_size() should fail if the file does not exist.