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.17467589 0.53157354 0.49363702 0.77930863 0.20417834 0.71339728 #> [7] 0.06521611 0.35420680 0.82519942 0.27381825 #> attr(,"tags") #> [1] "cacheId:f024b63398f829eb00833e3e0d1cc753" #> attr(,"newCache") #> [1] TRUE #> attr(,"call") #> [1] "" #> #> [[2]] #> [1] 0.17648861 0.24368546 1.62354888 0.11203808 -0.13399701 -1.91008747 #> [7] -0.27923724 -0.31344598 1.06730788 0.07003485 #> attr(,"tags") #> [1] "cacheId:b7eae7c361dfb6d161192321de6bc893" #> attr(,"newCache") #> [1] TRUE #> attr(,"call") #> [1] "" #>
# clear out any stub artifacts showCache(tmpDir)
#> Cache size:
#> Total (including Rasters): 12.4 Kb
#> Selected objects (not including Rasters): 430 bytes
#> artifact tagKey #> 1: 62d8bd92cc8e10d443f1b624916573d6 format #> 2: 62d8bd92cc8e10d443f1b624916573d6 name #> 3: 62d8bd92cc8e10d443f1b624916573d6 class #> 4: 62d8bd92cc8e10d443f1b624916573d6 date #> 5: 62d8bd92cc8e10d443f1b624916573d6 cacheId #> 6: 62d8bd92cc8e10d443f1b624916573d6 function #> 7: 62d8bd92cc8e10d443f1b624916573d6 object.size #> 8: 62d8bd92cc8e10d443f1b624916573d6 accessed #> 9: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 10: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 11: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 12: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 13: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 14: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 15: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 16: 62d8bd92cc8e10d443f1b624916573d6 preDigest #> 17: 62d8bd92cc8e10d443f1b624916573d6 preDigest #> 18: 645af519be4e5e3a0ab2631ff4ca64ab format #> 19: 645af519be4e5e3a0ab2631ff4ca64ab name #> 20: 645af519be4e5e3a0ab2631ff4ca64ab class #> 21: 645af519be4e5e3a0ab2631ff4ca64ab date #> 22: 645af519be4e5e3a0ab2631ff4ca64ab cacheId #> 23: 645af519be4e5e3a0ab2631ff4ca64ab function #> 24: 645af519be4e5e3a0ab2631ff4ca64ab object.size #> 25: 645af519be4e5e3a0ab2631ff4ca64ab accessed #> 26: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 27: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 28: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 29: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 30: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 31: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 32: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 33: 645af519be4e5e3a0ab2631ff4ca64ab preDigest #> 34: 645af519be4e5e3a0ab2631ff4ca64ab preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2018-07-13 21:42:10 #> 2: Cache 2018-07-13 21:42:10 #> 3: numeric 2018-07-13 21:42:10 #> 4: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 5: f024b63398f829eb00833e3e0d1cc753 2018-07-13 21:42:10 #> 6: f 2018-07-13 21:42:10 #> 7: 784 2018-07-13 21:42:10 #> 8: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 9: withCallingHandlers 2018-07-13 21:42:10 #> 10: saveRDS 2018-07-13 21:42:10 #> 11: do.call 2018-07-13 21:42:10 #> 12: build_site_local 2018-07-13 21:42:10 #> 13: build_reference 2018-07-13 21:42:10 #> 14: data_reference_topic 2018-07-13 21:42:10 #> 15: try 2018-07-13 21:42:10 #> 16: n:52ad08b1270ae9be9c0a12805d408433 2018-07-13 21:42:10 #> 17: .FUN:d2631d24c3b38b89c7bdd4ab7faaaac3 2018-07-13 21:42:10 #> 18: rda 2018-07-13 21:42:10 #> 19: Cache 2018-07-13 21:42:10 #> 20: numeric 2018-07-13 21:42:10 #> 21: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 22: b7eae7c361dfb6d161192321de6bc893 2018-07-13 21:42:10 #> 23: f 2018-07-13 21:42:10 #> 24: 784 2018-07-13 21:42:10 #> 25: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 26: withCallingHandlers 2018-07-13 21:42:10 #> 27: saveRDS 2018-07-13 21:42:10 #> 28: do.call 2018-07-13 21:42:10 #> 29: build_site_local 2018-07-13 21:42:10 #> 30: build_reference 2018-07-13 21:42:11 #> 31: data_reference_topic 2018-07-13 21:42:11 #> 32: try 2018-07-13 21:42:11 #> 33: n:52ad08b1270ae9be9c0a12805d408433 2018-07-13 21:42:11 #> 34: .FUN:7e9a928f110f80b3612e71883a6ec1f4 2018-07-13 21:42:11 #> 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): 12.2 Kb
#> Selected objects (not including Rasters): 224 bytes
#> artifact tagKey #> 1: 62d8bd92cc8e10d443f1b624916573d6 format #> 2: 62d8bd92cc8e10d443f1b624916573d6 name #> 3: 62d8bd92cc8e10d443f1b624916573d6 class #> 4: 62d8bd92cc8e10d443f1b624916573d6 date #> 5: 62d8bd92cc8e10d443f1b624916573d6 cacheId #> 6: 62d8bd92cc8e10d443f1b624916573d6 function #> 7: 62d8bd92cc8e10d443f1b624916573d6 object.size #> 8: 62d8bd92cc8e10d443f1b624916573d6 accessed #> 9: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 10: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 11: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 12: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 13: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 14: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 15: 62d8bd92cc8e10d443f1b624916573d6 otherFunctions #> 16: 62d8bd92cc8e10d443f1b624916573d6 preDigest #> 17: 62d8bd92cc8e10d443f1b624916573d6 preDigest #> 18: 645af519be4e5e3a0ab2631ff4ca64ab format #> 19: 645af519be4e5e3a0ab2631ff4ca64ab name #> 20: 645af519be4e5e3a0ab2631ff4ca64ab class #> 21: 645af519be4e5e3a0ab2631ff4ca64ab date #> 22: 645af519be4e5e3a0ab2631ff4ca64ab cacheId #> 23: 645af519be4e5e3a0ab2631ff4ca64ab function #> 24: 645af519be4e5e3a0ab2631ff4ca64ab object.size #> 25: 645af519be4e5e3a0ab2631ff4ca64ab accessed #> 26: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 27: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 28: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 29: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 30: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 31: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 32: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 33: 645af519be4e5e3a0ab2631ff4ca64ab preDigest #> 34: 645af519be4e5e3a0ab2631ff4ca64ab preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2018-07-13 21:42:10 #> 2: Cache 2018-07-13 21:42:10 #> 3: numeric 2018-07-13 21:42:10 #> 4: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 5: f024b63398f829eb00833e3e0d1cc753 2018-07-13 21:42:10 #> 6: f 2018-07-13 21:42:10 #> 7: 784 2018-07-13 21:42:10 #> 8: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 9: withCallingHandlers 2018-07-13 21:42:10 #> 10: saveRDS 2018-07-13 21:42:10 #> 11: do.call 2018-07-13 21:42:10 #> 12: build_site_local 2018-07-13 21:42:10 #> 13: build_reference 2018-07-13 21:42:10 #> 14: data_reference_topic 2018-07-13 21:42:10 #> 15: try 2018-07-13 21:42:10 #> 16: n:52ad08b1270ae9be9c0a12805d408433 2018-07-13 21:42:10 #> 17: .FUN:d2631d24c3b38b89c7bdd4ab7faaaac3 2018-07-13 21:42:10 #> 18: rda 2018-07-13 21:42:10 #> 19: Cache 2018-07-13 21:42:10 #> 20: numeric 2018-07-13 21:42:10 #> 21: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 22: b7eae7c361dfb6d161192321de6bc893 2018-07-13 21:42:10 #> 23: f 2018-07-13 21:42:10 #> 24: 784 2018-07-13 21:42:10 #> 25: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 26: withCallingHandlers 2018-07-13 21:42:10 #> 27: saveRDS 2018-07-13 21:42:10 #> 28: do.call 2018-07-13 21:42:10 #> 29: build_site_local 2018-07-13 21:42:10 #> 30: build_reference 2018-07-13 21:42:11 #> 31: data_reference_topic 2018-07-13 21:42:11 #> 32: try 2018-07-13 21:42:11 #> 33: n:52ad08b1270ae9be9c0a12805d408433 2018-07-13 21:42:11 #> 34: .FUN:7e9a928f110f80b3612e71883a6ec1f4 2018-07-13 21:42:11 #> tagValue createdDate
# run clearStubArtifacts suppressWarnings(clearStubArtifacts(tmpDir)) showCache(tmpDir) # stubs are removed
#> Cache size:
#> Total (including Rasters): 12.2 Kb
#> Selected objects (not including Rasters): 224 bytes
#> artifact tagKey #> 1: 645af519be4e5e3a0ab2631ff4ca64ab format #> 2: 645af519be4e5e3a0ab2631ff4ca64ab name #> 3: 645af519be4e5e3a0ab2631ff4ca64ab class #> 4: 645af519be4e5e3a0ab2631ff4ca64ab date #> 5: 645af519be4e5e3a0ab2631ff4ca64ab cacheId #> 6: 645af519be4e5e3a0ab2631ff4ca64ab function #> 7: 645af519be4e5e3a0ab2631ff4ca64ab object.size #> 8: 645af519be4e5e3a0ab2631ff4ca64ab accessed #> 9: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 10: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 11: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 12: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 13: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 14: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 15: 645af519be4e5e3a0ab2631ff4ca64ab otherFunctions #> 16: 645af519be4e5e3a0ab2631ff4ca64ab preDigest #> 17: 645af519be4e5e3a0ab2631ff4ca64ab preDigest #> tagValue createdDate #> 1: rda 2018-07-13 21:42:10 #> 2: Cache 2018-07-13 21:42:10 #> 3: numeric 2018-07-13 21:42:10 #> 4: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 5: b7eae7c361dfb6d161192321de6bc893 2018-07-13 21:42:10 #> 6: f 2018-07-13 21:42:10 #> 7: 784 2018-07-13 21:42:10 #> 8: 2018-07-13 21:42:10 2018-07-13 21:42:10 #> 9: withCallingHandlers 2018-07-13 21:42:10 #> 10: saveRDS 2018-07-13 21:42:10 #> 11: do.call 2018-07-13 21:42:10 #> 12: build_site_local 2018-07-13 21:42:10 #> 13: build_reference 2018-07-13 21:42:11 #> 14: data_reference_topic 2018-07-13 21:42:11 #> 15: try 2018-07-13 21:42:11 #> 16: n:52ad08b1270ae9be9c0a12805d408433 2018-07-13 21:42:11 #> 17: .FUN:7e9a928f110f80b3612e71883a6ec1f4 2018-07-13 21:42:11
# cleanup clearCache(tmpDir) unlink(tmpDir, recursive = TRUE)