bcgov / safepaths

An R 📦 to safely set & use a path to a private network
Apache License 2.0
3 stars 0 forks source link

use_network_path should throw an error for paths that don't exist #4

Closed boshek closed 3 years ago

boshek commented 3 years ago

In the absence of better auto-completion abilities I think it might be useful for use_network_path to check if the path you are inputting actually exists. I think that could happen here:

https://github.com/bcgov/safepaths/blob/1e7d84878120107b0977cc50e6d046cc3c5818bd/R/utils.R#L43

It would then throw that warning quickly so that a read_* function doesn't try to find a file that isn't there.

stephhazlitt commented 3 years ago

For MAC OS also you need to be connected to VPN and have the drive mounted and have an existing path, so some informative warning/error language here might help people de-bug among the possibilities.

ateucher commented 3 years ago

I don't think that's necessarily the best behaviour. What if you want to do:

dir.create(use_network_path("path_that_exists/dir_that_doesnt_yet_exist"))
ateucher commented 3 years ago

Or even

write.csv(x, use_network_path("path_that_exists/newfile.csv"))
stephhazlitt commented 3 years ago

So maybe it is just the message for things to double check (e.g. does the path exists, on a MAC OS is the drive mounted, are you connected to the network)?

boshek commented 3 years ago

Ah yes that is a good point. Also it looks like the read_ functions really take care of this for us anyways (and quite quickly too).