Skip to content

Commit

Permalink
enable cleaning of zenodo draft deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Apr 13, 2019
1 parent 9128e4d commit 9a659c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 10 additions & 3 deletions R/executeWorkflowJob.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ executeWorkflowJob <- function(config, jobdir){
entities <- config$metadata$content$entities
if(!is.null(entities)){

withZenodo <- sapply(actions, function(x){x$id=="zen4R-deposit-record"})
withZenodo <- any(sapply(actions, function(x){x$id=="zen4R-deposit-record"}))
if(withZenodo){
ZENODO_CONFIG <- config$software$output$zenodo_config
if(!is.null(ZENODO_CONFIG$properties$clean)) if(as.logical(ZENODO_CONFIG$properties$clean)){
config$logger.info("Zenodo action 'clean' activated: deleting all draft deposits prior to new deposits!")
config$software$output$zenodo$deleteRecords()
}
}

invisible(lapply(entities, function(entity){

Expand All @@ -45,8 +52,8 @@ executeWorkflowJob <- function(config, jobdir){
action$fun(entity, config, action$options)
}
#if zenodo is among actions, file upload (and possibly publish) to be managed here
if(any(withZenodo)){
zen_action <- actions[withZenodo][[1]]
if(withZenodo){
zen_action <- actions[sapply(actions, function(x){x$id=="zen4R-deposit-record"})][[1]]
act_options <- actions$options
act_options$depositWithFiles <- TRUE
zen_action$fun(entity, config, act_options)
Expand Down
3 changes: 3 additions & 0 deletions R/geoflow_software.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ register_software <- function(){
url = list(def = "Zenodo API URL. For sandbox tests, use 'https://sandbox.zenodo.org/api', otherwise provided by zen4R by default"),
token = list(def = "Zenodo user authentication token."),
logger = list(def = "Level for 'zen4R' logger messages (NULL, 'INFO' or 'DEBUG')")
),
attributes = list(
clean = list(def = "An option (TRUE/FALSE), to clean all draft Zenodo deposits prior to any new deposit")
)
)
)
Expand Down

0 comments on commit 9a659c8

Please sign in to comment.