Reroute symbolic links to files in directories that are to be deleted, e.g., by removeProject
.
This preserves the validity of links within the Gobbler registry.
rerouteLinks(to.delete, staging, url, dry.run = FALSE)
List of projects, assets or versions to be deleted.
Each entry should be a named list containing at least the project
name.
When deleting an asset, the inner list should contain an additional asset
name.
When deleting a version, the inner list should contain additional asset
and version
names.
Different inner lists may specify different projects, assets or versions.
String containing the path to the staging directory.
String containing the URL of the gobbler REST API.
Logical scalar indicating whether to perform a dry run of the rerouting.
A data frame where each row corresponds to a rerouting action, and contains the following columns:
path
, the path to a symbolic link in the registry that was changed by rerouting.
copy
, whether the link at path
was replaced by a copy of its target file.
If FALSE
, the link was merely updated to refer to a new target file.
source
, the path to the target file that caused rerouting of path
.
Specifically, this is a file in one of the to-be-deleted directories specified in to_delete
.
If copy = TRUE
, this is the original linked-to file that was copied to path
.
If dry.run=FALSE
, the registry is modified as described by the rerouting actions.
Otherwise, no modifications are performed to the registry.
Note that rerouting does not actually delete the directories specified in to.delete
.
Deletion requires separate invocations of removeProject
and friends -
preferably after the user has verified that rerouting was successful!
Rerouting is not necessary if to.delete
consists only of probational versions (or projects/assets containing only probational versions),
as the Gobbler should never create links to files in probational version directories.
removeProject
, removeAsset
and removeVersion
,
to remove the projects, assets and versions corresponding to to.delete
.
info <- startGobbler()
removeProject("test", info$staging, url=info$url) # start with a clean slate.
createProject("test", info$staging, url=info$url)
# Mocking up an asset so we have something interesting to reroute.
src <- allocateUploadDirectory(info$staging)
write(file=file.path(src, "foo"), "BAR")
uploadDirectory("test", "simple", "v1", src, staging=info$staging, url=info$url)
uploadDirectory("test", "simple", "v2", src, staging=info$staging, url=info$url)
uploadDirectory("test", "simple", "v3", src, staging=info$staging, url=info$url)
# Checking out how rerouting works when we delete the first version.
rerouteLinks(
list(list(project="test", asset="simple", version="v1")),
staging=info$staging,
url=info$url
)
#> copy path source
#> 1 TRUE test/simple/v2/foo test/simple/v1/foo
#> 2 FALSE test/simple/v3/foo test/simple/v1/foo