From 06def2604e1646531f6da8e3af00b840c4d496f1 Mon Sep 17 00:00:00 2001 From: wlandau Date: Tue, 3 Dec 2024 13:41:02 -0500 Subject: [PATCH] add error handling around ps file system calls --- NEWS.md | 1 + R/class_runtime.R | 14 +++++++++++++- R/utils_files.R | 8 +++++--- README.Rmd | 1 - README.md | 3 --- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3b335793..aabc4ccc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Allow branch references to contain multi-element `path` vectors with cloud metadata (#1382, @n8layman). * Avoid partial matches in internal code (#1384, @olivroy). +* Add error handling around calls to `ps::ps_disk_partitions()` and `ps::ps_fs_mount_point()`. ## Compatibility diff --git a/R/class_runtime.R b/R/class_runtime.R index 69ee32fa..b99b7dac 100644 --- a/R/class_runtime.R +++ b/R/class_runtime.R @@ -150,7 +150,19 @@ runtime_set_file_info <- function(runtime, store) { } runtime_file_systems <- function() { - info <- ps::ps_disk_partitions() + info <- tryCatch( + ps::ps_disk_partitions(), + # nocov start + error = function(condition) { + data.frame( + device = character(0L), + mountpoint = character(0L), + fstype = character(0L), + options = character(0L) + ) + } + # nocov end + ) out <- .subset2(info, "fstype") names(out) <- .subset2(info, "mountpoint") out diff --git a/R/utils_files.R b/R/utils_files.R index f66d0402..85ec07ff 100644 --- a/R/utils_files.R +++ b/R/utils_files.R @@ -109,9 +109,11 @@ trust_timestamps <- function(path) { file_systems <- runtime_file_systems() tar_runtime$file_systems <- file_systems } - mounts <- ps::ps_fs_mount_point(existing) - types <- as.character(file_systems[mounts]) - trust[exists] <- !(types %in% unsafe) + try({ + mounts <- ps::ps_fs_mount_point(existing) + types <- as.character(file_systems[mounts]) + trust[exists] <- !(types %in% unsafe) + }, silent = TRUE) } trust } diff --git a/README.Rmd b/README.Rmd index 5f5ed8d9..83c662bf 100644 --- a/README.Rmd +++ b/README.Rmd @@ -117,7 +117,6 @@ Please read the [help guide](https://books.ropensci.org/targets/help.html) to le ## Deployment -* explains how to deploy a pipeline to RStudio Connect ([example code](https://github.com/sol-eng/targets-deployment-rsc)). * [`tar_github_actions()`](https://docs.ropensci.org/targets/reference/tar_github_actions.html) sets up a pipeline to run on GitHub Actions. The [minimal example](https://github.com/wlandau/targets-minimal) demonstrates this approach. ## Extending and customizing targets diff --git a/README.md b/README.md index 8234a11d..207ea4be 100644 --- a/README.md +++ b/README.md @@ -195,9 +195,6 @@ to ask for help using `targets`. ## Deployment -- explains how to deploy a - pipeline to RStudio Connect ([example - code](https://github.com/sol-eng/targets-deployment-rsc)). - [`tar_github_actions()`](https://docs.ropensci.org/targets/reference/tar_github_actions.html) sets up a pipeline to run on GitHub Actions. The [minimal example](https://github.com/wlandau/targets-minimal) demonstrates this