Skip to content

Commit

Permalink
Patch overwrite (#27)
Browse files Browse the repository at this point in the history
* implement cleaner overwrite logic, closes #25

* update pkgdown docs too

* update CRAN comments too
  • Loading branch information
cboettig authored Feb 6, 2019
1 parent 2e741b8 commit 5e8971b
Show file tree
Hide file tree
Showing 25 changed files with 98 additions and 63 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# piggyback 0.0.10

* Improve interface regarding `overwrite` behavior in `pb_upload()` (#25)
* Bugfixes for errors introduced in 0.0.9:
- Uploading of directory paths could cause download errors in `pb_download()`. (#24)
- Access all assets on a release instead of first 30. This could break upload and download. (#23, #24)
- Uploading of directory paths could cause download errors in `pb_download()`. (#24, #26)

# piggyback 0.0.9, 2019-01-08

Expand Down
37 changes: 29 additions & 8 deletions R/pb_upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#' @param name name for uploaded file. If not provided will use the basename of
#' `file` (i.e. filename without directory)
#' @param overwrite overwrite any existing file with the same name already
#' attached to the on release? Defaults to `TRUE`
#' @param use_timestamps logical, if `TRUE`, then files will only be downloaded
#' if timestamp on GitHub is newer than the local timestamp (if
#' `overwrite=TRUE`). Defaults to `TRUE`.
#' attached to the on release? Defaults to `use_timestamps`, only overwriting
#' those files which are older. Set to `TRUE` to always overwrite, or `FALSE`
#' to never overwrite existing files.
#' @param use_timestamps DEPRECATED. please use `overwrite="use_timestamps"`
#' @param show_progress logical, show a progress bar be shown for uploading?
#' Defaults to `TRUE`.
#' @param .token GitHub authentication token. Typically set from an
Expand All @@ -33,8 +33,8 @@ pb_upload <- function(file,
repo = guess_repo(),
tag = "latest",
name = NULL,
overwrite = TRUE,
use_timestamps = TRUE,
overwrite = "use_timestamps",
use_timestamps = NULL,
show_progress = TRUE,
.token = get_token(),
dir = ".") {
Expand All @@ -57,15 +57,36 @@ pb_upload_file <- function(file,
repo = guess_repo(),
tag = "latest",
name = NULL,
overwrite = FALSE,
use_timestamps = TRUE,
overwrite = "use_timestamps",
use_timestamps = NULL,
show_progress = TRUE,
.token = get_token(),
dir = ".") {
if (!file.exists(file)) {
warning("file ", file, " does not exist")
return(NULL)
}
if(!is.null(use_timestamps)){
warning(paste("use_timestamps argument is deprecated",
"please set overwrite='use_timestamps'",
"instead."))
}


## Yeah, having two separate arguments was clearly a mistake!
## Code has been partially refactored now so that user just
## sets `overwrite` and we handle the twisted logic internally here:
use_timestamps <- switch (as.character(overwrite),
"TRUE" = FALSE,
"FALSE" = FALSE,
"use_timestamps" = TRUE
)
overwrite <- switch (as.character(overwrite),
"TRUE" = TRUE,
"FALSE" = FALSE,
"use_timestamps" = TRUE
)

progress <- httr::progress("up")
if (!show_progress) {
progress <- NULL
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/ropensci/piggyback",
"issueTracker": "https://github.com/ropensci/piggyback/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.9",
"version": "0.0.10",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -274,7 +274,7 @@
],
"releaseNotes": "https://github.com/ropensci/piggyback/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/piggyback/blob/master/README.md",
"fileSize": "274.26KB",
"fileSize": "275.036KB",
"contIntegration": [
"https://travis-ci.org/ropensci/piggyback",
"https://codecov.io/github/ropensci/piggyback?branch=master",
Expand Down
7 changes: 4 additions & 3 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Dear CRAN Maintainers,

We are pleased to submit an updated release of `piggyback` which improves the
existing documentation and provides a fallback mechanism in the event of
a interrupted network connection error when uploading a large numbers of files.
This release fixes a bug that was introduced in the previous release,
which prevented functions from seeing more than 30 file assets on
any given release. This release also improves the user interface
regarding the overwrite behavior, as detailed in NEWS.md.


## Test environments
Expand Down
2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/alternatives.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/intro.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 29 additions & 13 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/paper.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pb_delete.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pb_download.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pb_download_url.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pb_list.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pb_new_release.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/pb_track.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions docs/reference/pb_upload.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5e8971b

Please sign in to comment.