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_upload does not encode path delimiter as described in intro vignette #54

Closed tanho63 closed 2 years ago

tanho63 commented 2 years ago

It seems like the pb_upload function does not handle path delimiters as described in the intro vignette,

Vignette says:

Path names

GitHub assets attached to a release do not support file paths, and will convert most special characters (#, %, etc) to . or throw an error (e.g. for file names containing $, @, /). To preserve path information on uploading data, piggyback uses relative paths (relative to the working directory) in data file names, and encodes the system path delimiter as .2f (%2f is the HTML encoding of a literal /, but % cannot be used in asset names). piggyback functions will always show and use the decoded file names, e.g. data/mtcars.csv, but you’ll see data.2fmtcars.csv if you look at the release attachment on GitHub.

but it seems that the function actually strips down to basename by default https://github.com/ropensci/piggyback/blob/99f36e1f808f10e9fe162ab23d0da74fade1e016/R/pb_upload.R#L98-L101

Is this still desired? I can add - would look something like:

encoding:

file <- "inst/WORDLIST"
fs::path_split(file) |> unlist() |> paste(collapse = ".2f")
#> [1] "inst.2fWORDLIST"

decoding:

file <- ""inst.2fWORDLIST"
gsub(x = file,  pattern = ".2f",  replacement = "/",  fixed = TRUE)

and would require checking to see if that directory exists before downloading?

tanho63 commented 2 years ago

Further scanning suggests that #48 was meant to eliminate this functionality and instead just provide straight upload/download functionality

cboettig commented 2 years ago

corrrect