Skip to content

Commit

Permalink
Check if cache is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jun 16, 2016
1 parent 6ec14cb commit 4624451
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# httr 1.2.0.9000

* Fix bug with new cache creation code: need to check that
cache isn't an empty file.

# httr 1.2.0

## New features
Expand Down
4 changes: 3 additions & 1 deletion R/oauth-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ remove_cached_token <- function(token) {
}

load_cache <- function(cache_path) {
if (!file.exists(cache_path)) {
if (!file.exists(cache_path) || file_size(cache_path) == 0) {
list()
} else {
readRDS(cache_path)
}
}

file_size <- function(x) file.info(x, extra_cols = FALSE)$size

0 comments on commit 4624451

Please sign in to comment.