diff --git a/R/RcppExports.R b/R/RcppExports.R index c07abf3..8efd9f9 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -11,6 +11,8 @@ #' Specifically, mime type, encoding, possible file extensions and #' type description are returned as colums in the data frame along #' with \code{path}. +#' @note Various fields might not be available depending on the version +#' of \code{libmagic} you have installed. #' @references See \url{http://openpreservation.org/blog/2012/08/09/magic-editing-and-creation-primer/} #' for information on how to create your own \code{magic} database #' @export diff --git a/R/zzz.r b/R/zzz.r index 92ac626..5d477fa 100644 --- a/R/zzz.r +++ b/R/zzz.r @@ -26,8 +26,10 @@ magic_wand_file <- function(force=FALSE) { if (!dir.exists(cache)) dir.create(cache, showWarnings=FALSE) if (!dir.exists(cache)) return("system") - suppressWarnings(unzip(system.file("magic.mgc.zip", package="wand"), - exdir=cache, overwrite=force)) + if (!file.exists(file.path(rappdirs::user_cache_dir("wandr"), "magic.mgc"))) { + suppressWarnings(unzip(system.file("magic.mgc.zip", package="wand"), + exdir=cache, overwrite=force)) + } file.path(rappdirs::user_cache_dir("wandr"), "magic.mgc") diff --git a/tests/testthat/test-wand.R b/tests/testthat/test-wand.R index f4482d6..23ddde2 100644 --- a/tests/testthat/test-wand.R +++ b/tests/testthat/test-wand.R @@ -5,6 +5,7 @@ test_that("we can do something", { magic_wand_file()) tmp <- tmp$description tmp <- unlist(tmp, use.names=FALSE) + tmp <- sort(tmp) expect_that(tmp[2], equals("C source, ASCII text"))