Skip to content

Commit

Permalink
Return NULL for same versions, and don't store
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Mar 16, 2023
1 parent b42f803 commit 73e0f4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
16 changes: 8 additions & 8 deletions R/board_folder.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ pin_delete.pins_board_folder <- function(board, names, ...) {

#' @export
pin_store.pins_board_folder <- function(board, name, paths, metadata,
versioned = NULL, ...) {
versioned = NULL, ...) {
check_pin_name(name)
version <- version_setup(board, name, version_name(metadata), versioned = versioned)

version_dir <- fs::path(board$path, name, version)
fs::dir_create(version_dir)
write_meta(metadata, version_dir)
out_paths <- fs::file_copy(paths, version_dir, overwrite = TRUE)
fs::file_chmod(out_paths, "u=r")

if (!is.null(version)) {
version_dir <- fs::path(board$path, name, version)
fs::dir_create(version_dir)
write_meta(metadata, version_dir)
out_paths <- fs::file_copy(paths, version_dir, overwrite = TRUE)
fs::file_chmod(out_paths, "u=r")
}
name
}

Expand Down
8 changes: 2 additions & 6 deletions R/pin_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,13 @@ version_from_path <- function(x) {
out
}

version_setup <- function(board, name, new_version, versioned = NULL, call = caller_env()) {
version_setup <- function(board, name, new_version, versioned = NULL) {
if (pin_exists(board, name)) {
versions <- pin_versions(board, name)
old_version <- versions$version[[1]]
n_versions <- nrow(versions)
if (old_version == new_version) {
cli::cli_abort(c(
"The new version {.val {new_version}} is the same as the most recent version.",
i = "Did you try to create a new version with the same timestamp as the last version?"
),
call = call)
return(NULL)
}
} else {
n_versions <- 0
Expand Down

0 comments on commit 73e0f4d

Please sign in to comment.