Stub artifacts can result from several causes. The most common being erroneous removal of a file in the SQLite database. This can be caused sometimes if an archive object is being saved multiple times by multiple threads. This function will clear entries in the SQLite database which have no actual file with data.

clearStubArtifacts(repoDir = NULL)

# S4 method for ANY
clearStubArtifacts(repoDir = NULL)

Arguments

repoDir

A character denoting an existing directory of the repository for which metadata will be returned. If NULL (default), it will use the repoDir specified in archivist::setLocalRepo.

Value

Invoked for its side effect on the repoDir.

Examples

tmpDir <- file.path(tempdir(), "reproducible_examples", "clearStubArtifacts") lapply(c(runif, rnorm), function(f) { reproducible::Cache(f, 10, cacheRepo = tmpDir) })
#> [[1]] #> [1] 0.25488832 0.27304942 0.34963563 0.76105336 0.40419679 0.20539778 #> [7] 0.58729542 0.59820192 0.06929129 0.79705145 #> attr(,".Cache") #> attr(,".Cache")$newCache #> [1] TRUE #> #> attr(,"tags") #> [1] "cacheId:88dabbb6fbb67941" #> attr(,"call") #> [1] "" #> #> [[2]] #> [1] 0.72469120 -2.37751470 -0.06540921 -0.46970481 -0.28051629 0.57483659 #> [7] -0.20567685 0.23488051 0.11062832 0.27420223 #> attr(,".Cache") #> attr(,".Cache")$newCache #> [1] TRUE #> #> attr(,"tags") #> [1] "cacheId:87eee6212ba1ae0a" #> attr(,"call") #> [1] "" #>
# clear out any stub artifacts showCache(tmpDir)
#> Cache size:
#> Total (including Rasters): 552 bytes
#> Selected objects (not including Rasters): 552 bytes
#> artifact tagKey #> 1: 25b00e87c80ed1e9e45b36936fbae868 format #> 2: 25b00e87c80ed1e9e45b36936fbae868 name #> 3: 25b00e87c80ed1e9e45b36936fbae868 class #> 4: 25b00e87c80ed1e9e45b36936fbae868 date #> 5: 25b00e87c80ed1e9e45b36936fbae868 cacheId #> 6: 25b00e87c80ed1e9e45b36936fbae868 function #> 7: 25b00e87c80ed1e9e45b36936fbae868 object.size #> 8: 25b00e87c80ed1e9e45b36936fbae868 accessed #> 9: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 10: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 11: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 12: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 13: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 14: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 15: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 16: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 17: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 18: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 19: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 20: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 21: 25b00e87c80ed1e9e45b36936fbae868 preDigest #> 22: 25b00e87c80ed1e9e45b36936fbae868 preDigest #> 23: 63ca6e2ada8cc5192db268505bb6e0ac format #> 24: 63ca6e2ada8cc5192db268505bb6e0ac name #> 25: 63ca6e2ada8cc5192db268505bb6e0ac class #> 26: 63ca6e2ada8cc5192db268505bb6e0ac date #> 27: 63ca6e2ada8cc5192db268505bb6e0ac cacheId #> 28: 63ca6e2ada8cc5192db268505bb6e0ac function #> 29: 63ca6e2ada8cc5192db268505bb6e0ac object.size #> 30: 63ca6e2ada8cc5192db268505bb6e0ac accessed #> 31: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 32: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 33: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 34: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 35: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 36: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 37: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 38: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 39: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 40: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 41: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 42: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 43: 63ca6e2ada8cc5192db268505bb6e0ac preDigest #> 44: 63ca6e2ada8cc5192db268505bb6e0ac preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2019-11-17 08:37:29 #> 2: 25b00e87c80ed1e9e45b36936fbae868 2019-11-17 08:37:29 #> 3: numeric 2019-11-17 08:37:29 #> 4: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 5: 87eee6212ba1ae0a 2019-11-17 08:37:29 #> 6: f 2019-11-17 08:37:29 #> 7: 1104 2019-11-17 08:37:29 #> 8: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 9: saveRDS 2019-11-17 08:37:29 #> 10: do.call 2019-11-17 08:37:29 #> 11: build_site_local 2019-11-17 08:37:29 #> 12: build_reference 2019-11-17 08:37:29 #> 13: data_reference_topic 2019-11-17 08:37:29 #> 14: run_examples 2019-11-17 08:37:29 #> 15: highlight_examples 2019-11-17 08:37:29 #> 16: timing_fn 2019-11-17 08:37:29 #> 17: handle 2019-11-17 08:37:29 #> 18: try 2019-11-17 08:37:29 #> 19: withVisible 2019-11-17 08:37:29 #> 20: lapply 2019-11-17 08:37:29 #> 21: n:c5775c3b366fb719 2019-11-17 08:37:29 #> 22: .FUN:4f604aa46882b368 2019-11-17 08:37:29 #> 23: rda 2019-11-17 08:37:29 #> 24: 63ca6e2ada8cc5192db268505bb6e0ac 2019-11-17 08:37:29 #> 25: numeric 2019-11-17 08:37:29 #> 26: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 27: 88dabbb6fbb67941 2019-11-17 08:37:29 #> 28: f 2019-11-17 08:37:29 #> 29: 1104 2019-11-17 08:37:29 #> 30: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 31: saveRDS 2019-11-17 08:37:29 #> 32: do.call 2019-11-17 08:37:29 #> 33: build_site_local 2019-11-17 08:37:29 #> 34: build_reference 2019-11-17 08:37:29 #> 35: data_reference_topic 2019-11-17 08:37:29 #> 36: run_examples 2019-11-17 08:37:29 #> 37: highlight_examples 2019-11-17 08:37:29 #> 38: timing_fn 2019-11-17 08:37:29 #> 39: handle 2019-11-17 08:37:29 #> 40: try 2019-11-17 08:37:29 #> 41: withVisible 2019-11-17 08:37:29 #> 42: lapply 2019-11-17 08:37:29 #> 43: n:c5775c3b366fb719 2019-11-17 08:37:29 #> 44: .FUN:881ec847b7161f3c 2019-11-17 08:37:29 #> tagValue createdDate
file2Remove <- dir(file.path(tmpDir, "gallery"), full.name = TRUE)[1] file.remove(file2Remove)
#> [1] TRUE
showCache(tmpDir) # repository directory still thinks files are there
#> Cache size:
#> Total (including Rasters): 552 bytes
#> Selected objects (not including Rasters): 552 bytes
#> artifact tagKey #> 1: 25b00e87c80ed1e9e45b36936fbae868 format #> 2: 25b00e87c80ed1e9e45b36936fbae868 name #> 3: 25b00e87c80ed1e9e45b36936fbae868 class #> 4: 25b00e87c80ed1e9e45b36936fbae868 date #> 5: 25b00e87c80ed1e9e45b36936fbae868 cacheId #> 6: 25b00e87c80ed1e9e45b36936fbae868 function #> 7: 25b00e87c80ed1e9e45b36936fbae868 object.size #> 8: 25b00e87c80ed1e9e45b36936fbae868 accessed #> 9: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 10: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 11: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 12: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 13: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 14: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 15: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 16: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 17: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 18: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 19: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 20: 25b00e87c80ed1e9e45b36936fbae868 otherFunctions #> 21: 25b00e87c80ed1e9e45b36936fbae868 preDigest #> 22: 25b00e87c80ed1e9e45b36936fbae868 preDigest #> 23: 63ca6e2ada8cc5192db268505bb6e0ac format #> 24: 63ca6e2ada8cc5192db268505bb6e0ac name #> 25: 63ca6e2ada8cc5192db268505bb6e0ac class #> 26: 63ca6e2ada8cc5192db268505bb6e0ac date #> 27: 63ca6e2ada8cc5192db268505bb6e0ac cacheId #> 28: 63ca6e2ada8cc5192db268505bb6e0ac function #> 29: 63ca6e2ada8cc5192db268505bb6e0ac object.size #> 30: 63ca6e2ada8cc5192db268505bb6e0ac accessed #> 31: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 32: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 33: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 34: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 35: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 36: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 37: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 38: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 39: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 40: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 41: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 42: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 43: 63ca6e2ada8cc5192db268505bb6e0ac preDigest #> 44: 63ca6e2ada8cc5192db268505bb6e0ac preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2019-11-17 08:37:29 #> 2: 25b00e87c80ed1e9e45b36936fbae868 2019-11-17 08:37:29 #> 3: numeric 2019-11-17 08:37:29 #> 4: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 5: 87eee6212ba1ae0a 2019-11-17 08:37:29 #> 6: f 2019-11-17 08:37:29 #> 7: 1104 2019-11-17 08:37:29 #> 8: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 9: saveRDS 2019-11-17 08:37:29 #> 10: do.call 2019-11-17 08:37:29 #> 11: build_site_local 2019-11-17 08:37:29 #> 12: build_reference 2019-11-17 08:37:29 #> 13: data_reference_topic 2019-11-17 08:37:29 #> 14: run_examples 2019-11-17 08:37:29 #> 15: highlight_examples 2019-11-17 08:37:29 #> 16: timing_fn 2019-11-17 08:37:29 #> 17: handle 2019-11-17 08:37:29 #> 18: try 2019-11-17 08:37:29 #> 19: withVisible 2019-11-17 08:37:29 #> 20: lapply 2019-11-17 08:37:29 #> 21: n:c5775c3b366fb719 2019-11-17 08:37:29 #> 22: .FUN:4f604aa46882b368 2019-11-17 08:37:29 #> 23: rda 2019-11-17 08:37:29 #> 24: 63ca6e2ada8cc5192db268505bb6e0ac 2019-11-17 08:37:29 #> 25: numeric 2019-11-17 08:37:29 #> 26: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 27: 88dabbb6fbb67941 2019-11-17 08:37:29 #> 28: f 2019-11-17 08:37:29 #> 29: 1104 2019-11-17 08:37:29 #> 30: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 31: saveRDS 2019-11-17 08:37:29 #> 32: do.call 2019-11-17 08:37:29 #> 33: build_site_local 2019-11-17 08:37:29 #> 34: build_reference 2019-11-17 08:37:29 #> 35: data_reference_topic 2019-11-17 08:37:29 #> 36: run_examples 2019-11-17 08:37:29 #> 37: highlight_examples 2019-11-17 08:37:29 #> 38: timing_fn 2019-11-17 08:37:29 #> 39: handle 2019-11-17 08:37:29 #> 40: try 2019-11-17 08:37:29 #> 41: withVisible 2019-11-17 08:37:29 #> 42: lapply 2019-11-17 08:37:29 #> 43: n:c5775c3b366fb719 2019-11-17 08:37:29 #> 44: .FUN:881ec847b7161f3c 2019-11-17 08:37:29 #> tagValue createdDate
# run clearStubArtifacts suppressWarnings(clearStubArtifacts(tmpDir)) showCache(tmpDir) # stubs are removed
#> Cache size:
#> Total (including Rasters): 276 bytes
#> Selected objects (not including Rasters): 276 bytes
#> artifact tagKey #> 1: 63ca6e2ada8cc5192db268505bb6e0ac format #> 2: 63ca6e2ada8cc5192db268505bb6e0ac name #> 3: 63ca6e2ada8cc5192db268505bb6e0ac class #> 4: 63ca6e2ada8cc5192db268505bb6e0ac date #> 5: 63ca6e2ada8cc5192db268505bb6e0ac cacheId #> 6: 63ca6e2ada8cc5192db268505bb6e0ac function #> 7: 63ca6e2ada8cc5192db268505bb6e0ac object.size #> 8: 63ca6e2ada8cc5192db268505bb6e0ac accessed #> 9: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 10: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 11: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 12: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 13: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 14: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 15: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 16: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 17: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 18: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 19: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 20: 63ca6e2ada8cc5192db268505bb6e0ac otherFunctions #> 21: 63ca6e2ada8cc5192db268505bb6e0ac preDigest #> 22: 63ca6e2ada8cc5192db268505bb6e0ac preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2019-11-17 08:37:29 #> 2: 63ca6e2ada8cc5192db268505bb6e0ac 2019-11-17 08:37:29 #> 3: numeric 2019-11-17 08:37:29 #> 4: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 5: 88dabbb6fbb67941 2019-11-17 08:37:29 #> 6: f 2019-11-17 08:37:29 #> 7: 1104 2019-11-17 08:37:29 #> 8: 2019-11-17 08:37:29 2019-11-17 08:37:29 #> 9: saveRDS 2019-11-17 08:37:29 #> 10: do.call 2019-11-17 08:37:29 #> 11: build_site_local 2019-11-17 08:37:29 #> 12: build_reference 2019-11-17 08:37:29 #> 13: data_reference_topic 2019-11-17 08:37:29 #> 14: run_examples 2019-11-17 08:37:29 #> 15: highlight_examples 2019-11-17 08:37:29 #> 16: timing_fn 2019-11-17 08:37:29 #> 17: handle 2019-11-17 08:37:29 #> 18: try 2019-11-17 08:37:29 #> 19: withVisible 2019-11-17 08:37:29 #> 20: lapply 2019-11-17 08:37:29 #> 21: n:c5775c3b366fb719 2019-11-17 08:37:29 #> 22: .FUN:881ec847b7161f3c 2019-11-17 08:37:29 #> tagValue createdDate
# cleanup clearCache(tmpDir, ask = FALSE) unlink(tmpDir, recursive = TRUE)