ropensci / piggyback

:package: for using large(r) data files on GitHub
https://docs.ropensci.org/piggyback
GNU General Public License v3.0
185 stars 26 forks source link

pb_download complains with 404 warnings when downloading from private repos #121

Open tanho63 opened 9 months ago

tanho63 commented 9 months ago

piggyback fails with 404 errors in private repos now that it's trying the browser download url first.

pb_download(
  file = "iris_example.csv",
  dest = tempdir(),
  repo = "tanho63/piggyback-private",
  tag = "iris",
  .token = Sys.getenv("TAN_GH_TOKEN")
)
#> ℹ Downloading "iris_example.csv"...
#> Downloading: 29 B     Request failed [404]. Retrying in 1 seconds...
#> Downloading: 29 B     Request failed [404]. Retrying in 1.1 seconds...
#>  |====================================================================| 100%

We could include a check in pb_info() as to whether the repo is private or public, e.g.

gh::gh("/repos/tanho63/piggyback-private")$private
#> [1] TRUE

and skip the browser download attempt if private