Obtain a path to a subdirectory in the registry, possibly creating a local copy of the subdirectory's contents if the caller is not on the same filesystem as the registry.
fetchDirectory(
path,
registry,
url,
cache = NULL,
forceRemote = FALSE,
overwrite = FALSE,
concurrent = 1
)
String containing the relative path to a subdirectory within the registry.
This usually takes the form of PROJECT/ASSET/VERSION/*
, where path components should be separated by /
.
String containing a path to the registry.
String containing the URL to the Gobbler REST API. Only used for remote access.
String containing a path to a cache directory.
If NULL
, an appropriate location is automatically chosen.
Only used for remote access.
Logical scalar indicating whether to force remote access.
This will download all files in the path
via the REST API and cache them locally,
even if registry
is on the same filesystem as the caller.
Logical scalar indicating whether to overwrite the existing cache. Only used for remote access.
Integer specifying the number of concurrent downloads. Only used for remote access.
Path to the subdirectory on the caller's filesystem. This is either a path to the registry if it is accessible, or a path to a local cache of the registry's contents otherwise.
info <- startGobbler()
removeProject("test", info$staging, url=info$url) # start with a clean slate.
createProject("test", info$staging, url=info$url)
# Mocking up an upload.
src <- allocateUploadDirectory(info$staging)
write(file=file.path(src, "foo"), "BAR")
dir.create(file.path(src, "whee"))
write(file=file.path(src, "whee", "blah"), "stuff")
write(file=file.path(src, "whee2"), "more-stuff")
uploadDirectory("test", "simple", "v1", src, staging=info$staging, url=info$url)
# Now fetching the directory.
dir <- fetchDirectory("test/simple/v1", registry=info$registry, url=info$url)
dir
#> [1] "/tmp/Rtmpk5zsYr/file21928641d8f/test/simple/v1"
list.files(dir, recursive=TRUE)
#> [1] "foo" "whee/blah" "whee2"
# Or, forcing remote access:
cache <- tempfile()
dir1 <- fetchDirectory("test/simple/v1",
registry=info$registry,
url=info$url,
cache=cache,
forceRemote=TRUE
)
dir1
#> [1] "/tmp/Rtmpk5zsYr/file21945498d93/http%3A%2F%2F0.0.0.0%3A5114/REGISTRY/test/simple/v1"
list.files(dir1, recursive=TRUE)
#> [1] "foo" "whee/blah" "whee2"