(v3.0.1.9133) Fix the as.mo() session cache being cleared on every call in interactive sessions without an mo_source file

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2026-10-14 21:59:02 +02:00
1 parent 1a1a3abed1
commit e88faf8d40
3 files changed
+8 -5

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
Package: AMR
Version: 3.0.1.9132
Version: 3.0.1.9133
Date: 2026-10-14
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
+1 -1
View File
@@ -1,4 +1,4 @@
# AMR 3.0.1.9132
# AMR 3.0.1.9133
Planned as v3.1.0, mid October 2026.
+6 -3
View File
@@ -132,10 +132,11 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
stop_ifnot(destination %like% "[.]rds$", "the {.arg destination} must be a file location with file extension .rds.")
mo_source_destination <- path.expand(destination)
# earlier coercions might have been based on another mo_source
AMR_env$mo_previously_coerced <- new_coercion_cache()
if (is.null(path) || path %in% c(FALSE, "")) {
if (!is.null(AMR_env$mo_source) || file.exists(mo_source_destination)) {
# earlier coercions might have been based on this mo_source; get_mo_source() calls this function on every as.mo() call when no mo_source exists, so only reset when there was one
AMR_env$mo_previously_coerced <- new_coercion_cache()
}
AMR_env$mo_source <- NULL
if (file.exists(mo_source_destination)) {
unlink(mo_source_destination)
@@ -229,6 +230,8 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s
attr(df, "mo_source_timestamp") <- file.mtime(path)
saveRDS(df, mo_source_destination)
AMR_env$mo_source <- df
# earlier coercions might have been based on another mo_source
AMR_env$mo_previously_coerced <- new_coercion_cache()
message_(
action, " mo_source file '", font_bold(mo_source_destination),
"' (", formatted_filesize(mo_source_destination),