Compare 92e55c3 ... +1 ... 7429efe

Coverage Reach

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 2 of 62 files from the diff.
Other files ignored by Codecov
R/sysdata.rda has changed.
README.Rmd has changed.
README.md has changed.
NEWS.md has changed.

@@ -10,12 +10,14 @@
Loading
10 10
#'
11 11
#' @md
12 12
#' @param path path to a file
13 -
#' @param ... passed on to [guess_content_type()]
13 +
#' @param guess if `TRUE` (the default), calls [guess_content_type()] if
14 +
#'        no internal rules match the magic header
15 +
#' @param ... passed on to [guess_content_type()] if `guess` is `TRUE`
14 16
#' @return character vector
15 17
#' @export
16 18
#' @examples
17 -
#' get_content_type(system.file("extdat", "test.pdf", package="wand"))
18 -
get_content_type <- function(path, ...) {
19 +
#' get_content_type(system.file("extdat", "pass-through", "test.pdf", package="wand"))
20 +
get_content_type <- function(path, guess = TRUE, ...) {
19 21
20 22
  path <- path.expand(path[1])
21 23
  if (!file.exists(path)) stop("File not found.", call.=FALSE)
@@ -28,9 +30,14 @@
Loading
28 30
  if (all(c(0xCA,0xFE,0xBA,0xBE) == hdr[1:4])) return("application/java-vm")
29 31
30 32
  if (all(c(0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1) == hdr[1:8])) {
31 -
    guessed_name <- guess_content_type(path)
32 -
    if ((length(guessed_name) == 1) && (guessed_name != "???")) return(guessed_name)
33 +
34 +
    if (guess) {
35 +
      guessed_name <- guess_content_type(path)
36 +
      if ((length(guessed_name) == 1) && (guessed_name != "???")) return(guessed_name)
37 +
    }
38 +
33 39
    return("application/msword")
40 +
34 41
  }
35 42
36 43
  if (all(c(0x25,0x50,0x44,0x46,0x2d,0x31,0x2e) == hdr[1:7])) return("application/pdf")
@@ -107,8 +114,10 @@
Loading
107 114
    office_type <- check_office(hdr, path)
108 115
    if (length(office_type) > 0) return(office_type)
109 116
110 -
    guessed_name <- guess_content_type(path)
111 -
    if ((length(guessed_name) == 1) && (guessed_name != "???")) return(guessed_name)
117 +
    if (guess) {
118 +
      guessed_name <- guess_content_type(path)
119 +
      if ((length(guessed_name) == 1) && (guessed_name != "???")) return(guessed_name)
120 +
    }
112 121
113 122
    return("application/zip")
114 123
@@ -131,6 +140,7 @@
Loading
131 140
  if (all(c(0x00,0x00,0x01,0xBA) == hdr[1:4])) return("video/mpeg")
132 141
  if (all(c(0x00,0x00,0x01,0xB3) == hdr[1:4])) return("video/mpeg")
133 142
143 +
  if (!guess) return("???")
134 144
135 145
  return(guess_content_type(path, ...))
136 146

@@ -16,7 +16,7 @@
Loading
16 16
#' @return character vector
17 17
#' @export
18 18
#' @examples
19 -
#' guess_content_type(system.file("extdat", "test.pdf", package="wand"))
19 +
#' guess_content_type(system.file("extdat", "pass-through", "test.pdf", package="wand"))
20 20
guess_content_type <- function(path, not_found = "???", custom_db = NULL) {
21 21
22 22
  path <- path.expand(path[1])

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R +1.08% 56.45%
Project Totals (4 files) 56.45%
Loading