Skip to content

Commit

Permalink
Don't try to load source for remote files. Closes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Nov 16, 2016
1 parent 555bce8 commit 710de76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -4,3 +4,5 @@ profvis 0.3.2.9000
* Fixed [#68](https://github.com/rstudio/profvis/issues/68): Profvis threw an error when a package was installed using `devtools::install_github(args = "--with-keep.source")`.

* Fix bug where, when loading a profile that didn't contain memory data, profvis would throw an error. [#66](https://github.com/rstudio/profvis/pull/66)

* Fixed [#73](https://github.com/rstudio/profvis/issues/73): Profvis would throw an error if used on code sourced from a remote URL.
7 changes: 7 additions & 0 deletions R/file_contents.R
Expand Up @@ -20,6 +20,13 @@ fetch_cached <- function(filename, srcfile_cache) {
return(srcfile_cache[[filename]])
}

# Exit if file doesn't exist locally. In some cases (e.g. a URL like
# "http://xyz.com/" ) the `file()` call below can return a filehandle even
# when the file is not local, and then it will error when `readChar()` is
# called on the file. See https://github.com/rstudio/profvis/issues/73
if (!file.exists(filename))
return(NULL)

# If not in the cache, try to read the file
filehandle <- tryCatch(
file(filename, 'rb'),
Expand Down

0 comments on commit 710de76

Please sign in to comment.