Skip to content

Commit 641c476

Browse files
make hashing work if package is not root
1 parent 5fe4170 commit 641c476

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

R/prepare.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ libpath_touchstone <- function(ref) {
7272
}
7373

7474
#' When did the package sources change last?
75-
#'
75+
#' @inheritParams ref_install
7676
#' @keywords internal
77-
hash_pkg <- function() {
77+
hash_pkg <- function(path_pkg) {
78+
withr::local_dir(path_pkg)
7879
list(
7980
tools::md5sum(c(
80-
fs::dir_ls("R"),
81-
"DESCRIPTION",
81+
if (fs::dir_exists("R")) fs::dir_ls("R"),
82+
if (fs::file_exists("DESCRIPTION")) "DESCRIPTION",
8283
if (fs::dir_exists("scr")) fs::dir_info("scr")
8384
))
8485
)
@@ -91,15 +92,15 @@ hash_pkg <- function() {
9192
#' @inheritParams ref_install
9293
#' @keywords internal
9394
cache_up_to_date <- function(ref, path_pkg) {
94-
md5_hashes <- hash_pkg()
95+
md5_hashes <- hash_pkg(path_pkg)
9596
cache <- cache_get()
9697
identical(md5_hashes, cache$md5_hashes[cache$ref == ref & cache$path_pkg == path_pkg])
9798
}
9899

99100
#' @rdname cache_up_to_date
100101
#' @keywords internal
101102
cache_update <- function(ref, path_pkg) {
102-
md5_hashes <- hash_pkg()
103+
md5_hashes <- hash_pkg(path_pkg)
103104
cache <- cache_get()
104105
stopifnot(sum(cache$ref[cache$path_pkg == path_pkg] == ref) <= 1)
105106
cache <- cache[(!(cache$ref == ref) & (cache$path_pkg == path_pkg)), ]

man/hash_pkg.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)