ropensci / osfr

R interface to the Open Science Framework (OSF)
https://docs.ropensci.org/osfr
Other
142 stars 27 forks source link

cannot download a single folder from root that has multiple folders #122

Closed jbullock35 closed 4 years ago

jbullock35 commented 4 years ago

I am using osfr 0.2.8. I find that osf_download() is able to download the contents of folders in some cases but not in others. The problem seems like a bug, but I may just be missing something.

Here is a minimal example. We are examining a project that has multiple folders in its root directory. I want to download only the "Experiment 2" folder, which itself contains other folders. That is, I want osf_download() to create an "Experiment 2" folder on my computer that is a copy of the one on the OSF site. But

osf_retrieve_node("66gf4") %>%
  osf_ls_files(pattern = "Experiment 2") %>%
  osf_download()

doesn't work. Instead, I get only this output:

Requesting folder 'Experiment 2' from OSF
Downloaded 0 file(s) from OSF folder 'Experiment 2'

By contrast, this code does work

osf_retrieve_node("66gf4") %>%
  osf_ls_files(path = "Experiment 2") %>%
  osf_download()    

but it isn't what I want, because it downloads only the folders in the "Experiment 2" folder, rather than the "Experiment 2" folder itself.

This issue seems related to, but distinct from, #86. Is it a bug, or is this the expected functionality?

jbullock35 commented 4 years ago

I see that I just needed to use the recurse argument when calling osf_download(). This code works as expected:

osf_retrieve_node("66gf4") %>%
  osf_ls_files(pattern = "Experiment 2") %>%
  osf_download(recurse = TRUE)