Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit b1c39e8

Browse files
authored
Merge pull request #50 from stemangiola/sqlite-xz
Sqlite XZ
2 parents e9c30e4 + 99c335d commit b1c39e8

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

R/query.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,26 @@ get_metadata <- function(
408408
#' @importFrom RSQLite SQLite SQLITE_RO
409409
#' @importFrom dplyr tbl
410410
#' @importFrom httr progress
411+
#' @importFrom cli cli_alert_info
411412
#'
412413
get_metadata_local <- function(
413-
remote_url = "https://object-store.rc.nectar.org.au/v1/AUTH_06d6e008e3e642da99d806ba3ea629c5/metadata-sqlite/metadata.sqlite",
414+
remote_url = "https://object-store.rc.nectar.org.au/v1/AUTH_06d6e008e3e642da99d806ba3ea629c5/metadata-sqlite/metadata.tar.xz",
414415
cache_directory = get_default_cache_dir()
415416
) {
417+
tar_path <- file.path(cache_directory, "metadata.tar.xz")
416418
sqlite_path <- file.path(cache_directory, "metadata.sqlite")
417-
sync_remote_file(
418-
remote_url,
419-
sqlite_path,
420-
progress(type = "down", con = stderr())
421-
)
419+
if (!file.exists(sqlite_path)){
420+
tar_dir <- tempdir()
421+
tar_file <- file.path(tar_dir, "metadata.tar.xz")
422+
cli_alert_info("Downloading tar archive")
423+
sync_remote_file(
424+
remote_url,
425+
tar_file,
426+
progress(type = "down", con = stderr())
427+
)
428+
cli_alert_info("Decompressing tar archive")
429+
untar(tar_file, exdir = cache_directory)
430+
}
422431
SQLite() |>
423432
dbConnect(drv = _, dbname = sqlite_path, flags = SQLITE_RO) |>
424433
tbl("metadata")

0 commit comments

Comments
 (0)