Skip to content

Commit

Permalink
fix files decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 14, 2024
1 parent 7f6515f commit c90f215
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/ZenodoRecord.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ ZenodoRecord <- R6Class("ZenodoRecord",

#invenio model
self$access = obj$access
self$links = obj$links
self$files = lapply(obj$files$entries, function(file){
list(
filename = if(!is.null(file$filename)) file$filename else file$key,
filesize = if(!is.null(file$filesize)) file$filesize else file$size,
checksum = if(!startsWith(file$checksum, "md5:")) file$checksum else unlist(strsplit(file$checksum, "md5:"))[2],
download = if(!is.null(file$links$download)) file$links$download else file$links$self
download = if(!is.null(file$links$download)) file$links$download else file.path(self$links$self, sprintf("files/%s/content", file$key))
)
})
self$id = obj$id
self$links = obj$links
self$metadata = obj$metadata
resource_type = self$metadata$resource_type
if(!is.null(resource_type)){
Expand Down Expand Up @@ -1288,7 +1288,7 @@ ZenodoRecord <- R6Class("ZenodoRecord",
if (!quiet){
infoMsg = sprintf("Downloading file '%s' - size: %s\n",
file$filename, human_filesize(file$filesize))
cli::cli_alert_info(infoMSg)
cli::cli_alert_info(infoMsg)
cat(paste("[zen4R][INFO]", infoMsg))
}
target_file <- file.path(path, file$filename)
Expand Down Expand Up @@ -1521,7 +1521,7 @@ ZenodoRecord <- R6Class("ZenodoRecord",
#' @return a \code{data.frame} with the record versions
getVersions = function(){

record_type <- if(self$state == "done") "record" else if(self$state == "unsubmitted") "deposit"
record_type <- if(self$is_published) "record" else if(self$is_draft) "deposit"
ref_link <- if(record_type == "record") "latest_html" else if(record_type == "deposit") "latest_draft_html"
zenodo_url <- paste0(unlist(strsplit(self$links[[ref_link]], paste0("/", record_type)))[1],"/api")
zenodo <- ZenodoManager$new(url = zenodo_url)
Expand Down

0 comments on commit c90f215

Please sign in to comment.