Open richfitz opened 6 years ago
Yeah I'm not entirely sure yet how to deal with this. If you are downloading many files, and one fails, should the entire operation be aborted? What about files that you already downloaded?
My thoughts:
I personally really dislike warnings in R - they're easily lost and don't get printed at a useful time. If it's informational and requires no user action I prefer message and if it's likely something terrible happened then I prefer errors (same idea as https://dave.cheney.net/2015/11/05/lets-talk-about-logging) but I recognise that's just a personal view.
How about return a logical vector TRUE/FALSE for success and include a must_work
argument (so that if all files must be transferred successfully then it's easy to throw).
Because of the manipulation of global state you can't make the whole thing atomic (all work or none work) and scp itself doesn't try.
What about
options(warn=2)
With tryCatch one can easily capture errors or warnings
exception = tryCatch(
{
# something you want to do
},
error = function(e) e,
warning = function(w) w
)
if (inherits(exception, 'warning')) {
stop('An error occured.')
}
ssh::scp_download
just warns if upload fails rather than errors - can this be turned into an error (even if it's an option that one has to set)?