From 7187343aab86550af29992193ff2fd47813e599d Mon Sep 17 00:00:00 2001 From: George Stagg Date: Tue, 6 Aug 2024 14:58:04 +0100 Subject: [PATCH] Remove PACKAGES files if Wasm repo is empty --- R/repo.R | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/R/repo.R b/R/repo.R index b4cb7ad..83e8cca 100644 --- a/R/repo.R +++ b/R/repo.R @@ -278,7 +278,17 @@ update_repo <- function(package_info, } update_packages <- function(contrib_src, contrib_bin) { - tools::write_PACKAGES(contrib_src, verbose = TRUE) - tools::write_PACKAGES(contrib_bin, verbose = TRUE, type = "mac.binary") - invisible(NULL) + if (any(c( + grepl(".tar.gz", fs::dir_ls(contrib_src)), + grepl(".tgz", fs::dir_ls(contrib_bin)) + ))) { + tools::write_PACKAGES(contrib_src, verbose = TRUE) + tools::write_PACKAGES(contrib_bin, verbose = TRUE, type = "mac.binary") + invisible(TRUE) + } else { + # If the repo is empty, just wipe PACKAGES + fs::dir_delete(contrib_src) + fs::dir_delete(contrib_bin) + invisible(FALSE) + } }