From e88faf8d40ebdee692706a702e8903c5f7417b18 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Wed, 14 Oct 2026 21:59:02 +0200 Subject: [PATCH] (v3.0.1.9133) Fix the as.mo() session cache being cleared on every call in interactive sessions without an mo_source file --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/mo_source.R | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0e03489be..0d375a4b3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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) diff --git a/NEWS.md b/NEWS.md index 9ea295eea..805eb52d2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 3.0.1.9132 +# AMR 3.0.1.9133 Planned as v3.1.0, mid October 2026. diff --git a/R/mo_source.R b/R/mo_source.R index 72260db96..b66579997 100755 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -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),