Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/busy-indicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ spinnerOptions <- function(type = NULL, color = NULL, size = NULL, delay = NULL,
if (!is.null(type)) {
stopifnot(is.character(type) && length(type) == 1)
if (file.exists(type) && grepl("\\.svg$", type)) {
typeRaw <- readBin(type, "raw", n = file.info(type)$size)
typeRaw <- readBin(type, "raw", n = file.size(type))
url <- sprintf("url('data:image/svg+xml;base64,%s')", rawToBase64(typeRaw))
} else {
type <- rlang::arg_match(type, .busySpinnerTypes)
Expand Down
4 changes: 2 additions & 2 deletions R/middleware.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ staticHandler <- function(root) {
return(NULL)

content.type <- getContentType(abs.path)
response.content <- readBin(abs.path, 'raw', n=file.info(abs.path)$size)
response.content <- readBin(abs.path, 'raw', n=file.size(abs.path))
return(httpResponse(200, content.type, response.content))
})
}
Expand Down Expand Up @@ -456,7 +456,7 @@ getResponseContentLength <- function(response, deleteOwnedContent) {
if (deleteOwnedContent && isTRUE(response$content$owned)) {
on.exit(unlink(response$content$file, recursive = FALSE, force = FALSE), add = TRUE)
}
file.info(response$content$file)$size
file.size(response$content$file)
} else {
warning("HEAD request for unexpected content class ", class(response$content)[[1]])
NULL
Expand Down
2 changes: 1 addition & 1 deletion R/mock-session.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ MockShinySession <- R6Class(
#' @param file The file to be encoded
#' @param contentType The content type of the base64-encoded string
fileUrl = function(name, file, contentType='application/octet-stream') {
bytes <- file.info(file)$size
bytes <- file.size(file)
if (is.na(bytes))
return(NULL)

Expand Down
4 changes: 2 additions & 2 deletions R/reactives.R
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ coerceToFunc <- function(x) {
#' # This function returns the time that log_file was last modified
#' checkFunc = function() {
#' if (file.exists(log_file))
#' file.info(log_file)$mtime[1]
#' file.mtime(log_file[1])
#' else
#' ""
#' },
Expand Down Expand Up @@ -2127,7 +2127,7 @@ reactiveFileReader <- function(intervalMillis, session, filePath, readFunc, ...)
session = session,
checkFunc = function() {
path <- filePath()
info <- file.info(path)
info <- file.info(path, extra_cols = FALSE)
return(paste(path, info$mtime, info$size))
},
valueFunc = function() {
Expand Down
4 changes: 2 additions & 2 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ ShinySession <- R6Class(
saveRDS(values, tmpfile)
on.exit(unlink(tmpfile), add = TRUE)

content <- readBin(tmpfile, "raw", n = file.info(tmpfile)$size)
content <- readBin(tmpfile, "raw", n = file.size(tmpfile))
httpResponse(200, "application/octet-stream", content)

} else {
Expand Down Expand Up @@ -2096,7 +2096,7 @@ ShinySession <- R6Class(
fileUrl = function(name, file, contentType='application/octet-stream') {
"Return a URL for a file to be sent to the client. The file will be base64
encoded and embedded in the URL."
bytes <- file.info(file)$size
bytes <- file.size(file)
if (is.na(bytes))
return(NULL)

Expand Down
2 changes: 1 addition & 1 deletion R/shinyapp.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ initAutoReloadMonitor <- function(dir) {
files <- sort_c(
list.files(dir, pattern = filePattern, recursive = TRUE, ignore.case = TRUE)
)
times <- file.info(files)$mtime
times <- file.mtime(files)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.mtime() was added in R 3.2.0 -- should we add a Depends constraint to DESCRIPTION @gadenbuie?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gadenbuie more generally, would you like to get this one over the finish line (i.e., NEWS.md file, address suggestions, etc)?

names(times) <- files

if (is.null(lastValue)) {
Expand Down
2 changes: 1 addition & 1 deletion R/test.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ is_legacy_shinytest_dir <- function(path){
}

files <- dir(path, full.names = TRUE)
files <- files[!file.info(files)$isdir]
files <- files[!file.info(files, extra_cols = FALSE)$isdir]
if (length(files) == 0) {
return(FALSE)
}
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ find.file.ci <- function(...) {
# The function base::dir.exists was added in R 3.2.0, but for backward
# compatibility we need to add this function
dirExists <- function(paths) {
file.exists(paths) & file.info(paths)$isdir
file.exists(paths) & file.info(paths, extra_cols = FALSE)$isdir
}

# Removes empty directory (vectorized). This is needed because file.remove()
Expand Down Expand Up @@ -803,7 +803,7 @@ cachedFuncWithFile <- function(dir, file, func, case.sensitive = FALSE) {
file.path.ci(dir, file)
}

now <- file.info(fname)$mtime
now <- file.mtime(fname)
autoreload <- last_autoreload < cachedAutoReloadLastChanged$get()
if (autoreload || !identical(last_mtime_file, now)) {
value <<- func(fname, ...)
Expand Down Expand Up @@ -1329,7 +1329,7 @@ checkEncoding <- function(file) {
# world of consistency (falling back to getOption('encoding') will not help
# because native.enc is also normally UTF-8 based on *nix)
if (!isWindows()) return('UTF-8')
size <- file.info(file)[, 'size']
size <- file.info(file, extra_cols = FALSE)[, 'size']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size <- file.info(file, extra_cols = FALSE)[, 'size']
size <- file.size(file)

if (is.na(size)) stop('Cannot access the file ', file)
# BOM is 3 bytes, so if the file contains BOM, it must be at least 3 bytes
if (size < 3L) return('UTF-8')
Expand Down
2 changes: 1 addition & 1 deletion man/reactivePoll.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-plot-png.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("plotPNG()/startPNG() ignores NULL dimensions", {
f <- plotPNG(function() plot(1), width = NULL, height = NULL)
on.exit(unlink(f))
bits <- readBin(f, "raw", file.info(f)$size)
bits <- readBin(f, "raw", file.size(f))
expect_gt(length(bits), 0)
})
Loading