Closed zoey-rw closed 4 years ago
Thanks for the detailed report!
Weird that I cannot reproduce the error:
library(neonstore)
> neon_download(product = "DP1.00041.001", file_regex = "50[123].030", site = "BONA", type = "basic")
querying API [=============================] 100% eta: 0s
downloading [==============================] 100% eta: 0s
## running a second time doesn't download anything further, but no error either:
> neon_download(product = "DP1.00041.001", file_regex = "50[123].030", site = "BONA", type = "basic")
querying API [=============================] 100% eta: 0s
You're probably right about files
being "empty" instead of NULL, like you say we don't handle that case but I'm not sure what kind of empty it is. Can you track down what files
returns in your case? (e.g. is it a data.frame with 0 rows? an empty (length-1) character string ""
? A character(0L)
? (all these are different "empty" objects but all need to be handled differently!)
I'm pretty sure it's the last of these, since that's what x[grepl(pattern, x)]
creates if x is character vector and pattern doesn't match. I just pushed an edit to handle this case (and include a message). Can you install_github()
to test and see if that fixes things for you?
Closing as I believe the above mentioned commit https://github.com/cboettig/neonstore/commit/78019f7aa5ab73e66070e9b0f7cbadb1c2b634ec resolves this
Continuing conversation from https://github.com/cboettig/neonstore/issues/18#issuecomment-693719913 , but I think this is a separate, smaller issue!
When I download by site, things work the first time, but I got an error at site 5 when I re-ran this loop:
We can see the error does come from site "BONA":
Interrogating the error using internal functions:
Here's where the error is, I think -
files
is empty (nothing to download), but doesn't return NULL, so the function continues and returns the same error below.I'm not sure why the error would be specific to this site, though. Here's my sessionInfo:
https://github.com/cboettig/neonstore/blob/f78e9d37a9689d32534c45d3ae7c973d78581b56/R/neon_download.R#L115