From db85941e75351d92401f5abec2d7b6611cb5746d Mon Sep 17 00:00:00 2001 From: Ben Raymond Date: Mon, 8 Jul 2024 10:25:58 +1000 Subject: [PATCH] use fastrls if installed instead of fs::dir_ls when building cache --- DESCRIPTION | 21 +++++++++------------ R/000-raadfiles-admin.R | 13 ++++++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f355077..f23ef9d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,10 @@ Package: raadfiles Title: File Database Management for 'raadtools' -Version: 0.1.4.9007 -Authors@R: c( - person("Michael D.","Sumner", role = c("aut", "cre"), email = "michael.sumner@aad.gov.au"), - person("Ben", "Raymond", role = "ctb"), - person(given = "Kimberlee", - family = "Baldry", - role = c("ctb"), - comment = c(ORCID = "0000-0003-3286-8624")) - ) -Description: Tools for managing collections of files for the 'raad' family. +Version: 0.1.4.9008 +Authors@R: c(person("Michael D.","Sumner", role = c("aut", "cre"), email = "michael.sumner@aad.gov.au"), + person("Ben", "Raymond", role = "ctb"), + person("Kimberlee", "Baldry", role = c("ctb"), comment = c(ORCID = "0000-0003-3286-8624"))) +Description: Tools for managing collections of files for the 'raad' family. Depends: R (>= 3.3.0) Imports: @@ -24,5 +19,7 @@ Imports: License: GPL-3 Encoding: UTF-8 RoxygenNote: 7.2.3 -Suggests: testthat -Remotes: r-lib/fs +Suggests: + fastrls, + testthat +Remotes: r-lib/fs, AustralianAntarcticDivision/fastrls diff --git a/R/000-raadfiles-admin.R b/R/000-raadfiles-admin.R index e651dc4..a19caa6 100644 --- a/R/000-raadfiles-admin.R +++ b/R/000-raadfiles-admin.R @@ -332,16 +332,19 @@ run_build_raad_cache <- function() { adminpath <- dirname(raad_filedb_path(roots[i])) dir.create(adminpath, showWarnings = FALSE) dbpath <- raad_filedb_path(roots[i]) - filenames <- as.character(fs::dir_ls(roots[i], all = TRUE, recurse = TRUE, - ## no directory, FIFO, socket, character_device or block_device - type = c("file", "symlink"))) - if (is.null(filenames)) { + if (requireNamespace("fastrls", quietly = TRUE)) { + filenames <- as.character(fastrls::fastrls(roots[i], include_dirs = FALSE, n_threads = 4)) + } else { + filenames <- as.character(fs::dir_ls(roots[i], all = TRUE, recurse = TRUE, + ## no directory, FIFO, socket, character_device or block_device + type = c("file", "symlink"))) + } + if (is.null(filenames) || length(filenames) < 1) { files <- tibble::tibble(root = character(0), file = character(0)) } else { ## fix up root-less file filenames <- remove_leading_slash(gsub(roots[i], "", filenames)) - files <- tibble::tibble(root = roots[i], file = filenames) }