Skip to content

Commit

Permalink
Closes #1706 library(data.table) fails if "Packaged" field is not pre…
Browse files Browse the repository at this point in the history
…sent in DESCRIPTION

alternate approach to this issue which avoids call to try()
  • Loading branch information
restonslacker committed May 16, 2016
1 parent 2bb7b5c commit 159a4b5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions R/onAttach.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
# Runs when attached to search() path such as by library() or require()
if (interactive()) {
v = packageVersion("data.table")
d = try(read.dcf(system.file("DESCRIPTION", package="data.table"))[,"Packaged"])
if(inherits(d, "try-error")){
d = try(strsplit(read.dcf(system.file("DESCRIPTION", package="data.table"))[,"Built"], split="; ")$Built[3])
if(inherits(d, "try-error")){
return()
d = read.dcf(system.file("DESCRIPTION", package="data.table"), fields = c("Packaged", "Built"))
if(is.na(d[1])){
if(is.na(d[2])){
return() #neither field exists
} else{
d = unlist(strsplit(d[2], split="; "))[3]
}
} else {
d = d[1]
}

dev = as.integer(v[1,3])%%2 == 1 # version number odd
packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d))
if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********")
Expand Down

0 comments on commit 159a4b5

Please sign in to comment.