From 61c692e00852ce795094005fd6405a6066aac77e Mon Sep 17 00:00:00 2001 From: Geoffrey Poole Date: Wed, 15 Jan 2025 14:54:51 -0700 Subject: [PATCH] Issue 180: remove potentially large /tmp files Ref: Issue 180. When an odt or docx file is retrieved and processed using get_docx() or get_odt(), a potentially large file is written to /tmp. This patch proposed removing those /tmp files prior to returning the text contained within them. --- R/get-functions.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/get-functions.R b/R/get-functions.R index 9793682..94b6c30 100644 --- a/R/get-functions.R +++ b/R/get-functions.R @@ -181,7 +181,8 @@ get_odt <- function(path, source, ...) { txt <- txt[!grepl("^\\s*$", txt)] # Remove text which is just whitespace txt <- paste0(txt, collapse = "\n") - + + unlink(path, recursive = TRUE) data.frame(text = txt, stringsAsFactors = FALSE) } @@ -198,6 +199,7 @@ get_docx <- function(path, source, ...) { txt <- txt[!grepl("^\\s*$", txt)] # Remove text which is just whitespace txt <- paste0(txt, collapse = "\n") + unlink(path, recursive = TRUE) data.frame(text = txt, stringsAsFactors = FALSE) }