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.859625102 0.757621128 0.926860752 0.081588733 0.049136837 0.345142181 #> [7] 0.002873588 0.678100822 0.604252266 0.119109327 #> attr(,".Cache") #> attr(,".Cache")$newCache #> [1] TRUE #> #> attr(,"tags") #> [1] "cacheId:88dabbb6fbb67941" #> attr(,"call") #> [1] "" #> #> [[2]] #> [1] 1.02457159 -0.65918555 -0.38630438 -0.24249895 0.22059324 -1.48109003 #> [7] 0.72469120 -2.37751470 -0.06540921 -0.46970481 #> 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: 6ca91e088f858919397101bea3065426 format #> 2: 6ca91e088f858919397101bea3065426 name #> 3: 6ca91e088f858919397101bea3065426 class #> 4: 6ca91e088f858919397101bea3065426 date #> 5: 6ca91e088f858919397101bea3065426 cacheId #> 6: 6ca91e088f858919397101bea3065426 function #> 7: 6ca91e088f858919397101bea3065426 object.size #> 8: 6ca91e088f858919397101bea3065426 accessed #> 9: 6ca91e088f858919397101bea3065426 otherFunctions #> 10: 6ca91e088f858919397101bea3065426 otherFunctions #> 11: 6ca91e088f858919397101bea3065426 otherFunctions #> 12: 6ca91e088f858919397101bea3065426 otherFunctions #> 13: 6ca91e088f858919397101bea3065426 otherFunctions #> 14: 6ca91e088f858919397101bea3065426 otherFunctions #> 15: 6ca91e088f858919397101bea3065426 otherFunctions #> 16: 6ca91e088f858919397101bea3065426 otherFunctions #> 17: 6ca91e088f858919397101bea3065426 otherFunctions #> 18: 6ca91e088f858919397101bea3065426 otherFunctions #> 19: 6ca91e088f858919397101bea3065426 otherFunctions #> 20: 6ca91e088f858919397101bea3065426 otherFunctions #> 21: 6ca91e088f858919397101bea3065426 preDigest #> 22: 6ca91e088f858919397101bea3065426 preDigest #> 23: a71865def6b1292c9213bb755ea4c920 format #> 24: a71865def6b1292c9213bb755ea4c920 name #> 25: a71865def6b1292c9213bb755ea4c920 class #> 26: a71865def6b1292c9213bb755ea4c920 date #> 27: a71865def6b1292c9213bb755ea4c920 cacheId #> 28: a71865def6b1292c9213bb755ea4c920 function #> 29: a71865def6b1292c9213bb755ea4c920 object.size #> 30: a71865def6b1292c9213bb755ea4c920 accessed #> 31: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 32: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 33: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 34: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 35: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 36: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 37: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 38: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 39: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 40: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 41: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 42: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 43: a71865def6b1292c9213bb755ea4c920 preDigest #> 44: a71865def6b1292c9213bb755ea4c920 preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2019-03-18 10:05:58 #> 2: 6ca91e088f858919397101bea3065426 2019-03-18 10:05:58 #> 3: numeric 2019-03-18 10:05:58 #> 4: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 5: 88dabbb6fbb67941 2019-03-18 10:05:58 #> 6: f 2019-03-18 10:05:58 #> 7: 1104 2019-03-18 10:05:58 #> 8: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 9: saveRDS 2019-03-18 10:05:58 #> 10: do.call 2019-03-18 10:05:58 #> 11: build_site_local 2019-03-18 10:05:58 #> 12: build_reference 2019-03-18 10:05:58 #> 13: data_reference_topic 2019-03-18 10:05:58 #> 14: as_data 2019-03-18 10:05:58 #> 15: as_data.tag_examples 2019-03-18 10:05:58 #> 16: timing_fn 2019-03-18 10:05:58 #> 17: handle 2019-03-18 10:05:58 #> 18: try 2019-03-18 10:05:58 #> 19: withVisible 2019-03-18 10:05:58 #> 20: lapply 2019-03-18 10:05:58 #> 21: n:c5775c3b366fb719 2019-03-18 10:05:58 #> 22: .FUN:881ec847b7161f3c 2019-03-18 10:05:58 #> 23: rda 2019-03-18 10:05:58 #> 24: a71865def6b1292c9213bb755ea4c920 2019-03-18 10:05:58 #> 25: numeric 2019-03-18 10:05:58 #> 26: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 27: 87eee6212ba1ae0a 2019-03-18 10:05:58 #> 28: f 2019-03-18 10:05:58 #> 29: 1104 2019-03-18 10:05:58 #> 30: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 31: saveRDS 2019-03-18 10:05:58 #> 32: do.call 2019-03-18 10:05:58 #> 33: build_site_local 2019-03-18 10:05:58 #> 34: build_reference 2019-03-18 10:05:58 #> 35: data_reference_topic 2019-03-18 10:05:58 #> 36: as_data 2019-03-18 10:05:58 #> 37: as_data.tag_examples 2019-03-18 10:05:58 #> 38: timing_fn 2019-03-18 10:05:58 #> 39: handle 2019-03-18 10:05:58 #> 40: try 2019-03-18 10:05:58 #> 41: withVisible 2019-03-18 10:05:58 #> 42: lapply 2019-03-18 10:05:58 #> 43: n:c5775c3b366fb719 2019-03-18 10:05:58 #> 44: .FUN:4f604aa46882b368 2019-03-18 10:05:58 #> 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: 6ca91e088f858919397101bea3065426 format #> 2: 6ca91e088f858919397101bea3065426 name #> 3: 6ca91e088f858919397101bea3065426 class #> 4: 6ca91e088f858919397101bea3065426 date #> 5: 6ca91e088f858919397101bea3065426 cacheId #> 6: 6ca91e088f858919397101bea3065426 function #> 7: 6ca91e088f858919397101bea3065426 object.size #> 8: 6ca91e088f858919397101bea3065426 accessed #> 9: 6ca91e088f858919397101bea3065426 otherFunctions #> 10: 6ca91e088f858919397101bea3065426 otherFunctions #> 11: 6ca91e088f858919397101bea3065426 otherFunctions #> 12: 6ca91e088f858919397101bea3065426 otherFunctions #> 13: 6ca91e088f858919397101bea3065426 otherFunctions #> 14: 6ca91e088f858919397101bea3065426 otherFunctions #> 15: 6ca91e088f858919397101bea3065426 otherFunctions #> 16: 6ca91e088f858919397101bea3065426 otherFunctions #> 17: 6ca91e088f858919397101bea3065426 otherFunctions #> 18: 6ca91e088f858919397101bea3065426 otherFunctions #> 19: 6ca91e088f858919397101bea3065426 otherFunctions #> 20: 6ca91e088f858919397101bea3065426 otherFunctions #> 21: 6ca91e088f858919397101bea3065426 preDigest #> 22: 6ca91e088f858919397101bea3065426 preDigest #> 23: a71865def6b1292c9213bb755ea4c920 format #> 24: a71865def6b1292c9213bb755ea4c920 name #> 25: a71865def6b1292c9213bb755ea4c920 class #> 26: a71865def6b1292c9213bb755ea4c920 date #> 27: a71865def6b1292c9213bb755ea4c920 cacheId #> 28: a71865def6b1292c9213bb755ea4c920 function #> 29: a71865def6b1292c9213bb755ea4c920 object.size #> 30: a71865def6b1292c9213bb755ea4c920 accessed #> 31: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 32: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 33: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 34: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 35: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 36: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 37: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 38: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 39: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 40: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 41: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 42: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 43: a71865def6b1292c9213bb755ea4c920 preDigest #> 44: a71865def6b1292c9213bb755ea4c920 preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2019-03-18 10:05:58 #> 2: 6ca91e088f858919397101bea3065426 2019-03-18 10:05:58 #> 3: numeric 2019-03-18 10:05:58 #> 4: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 5: 88dabbb6fbb67941 2019-03-18 10:05:58 #> 6: f 2019-03-18 10:05:58 #> 7: 1104 2019-03-18 10:05:58 #> 8: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 9: saveRDS 2019-03-18 10:05:58 #> 10: do.call 2019-03-18 10:05:58 #> 11: build_site_local 2019-03-18 10:05:58 #> 12: build_reference 2019-03-18 10:05:58 #> 13: data_reference_topic 2019-03-18 10:05:58 #> 14: as_data 2019-03-18 10:05:58 #> 15: as_data.tag_examples 2019-03-18 10:05:58 #> 16: timing_fn 2019-03-18 10:05:58 #> 17: handle 2019-03-18 10:05:58 #> 18: try 2019-03-18 10:05:58 #> 19: withVisible 2019-03-18 10:05:58 #> 20: lapply 2019-03-18 10:05:58 #> 21: n:c5775c3b366fb719 2019-03-18 10:05:58 #> 22: .FUN:881ec847b7161f3c 2019-03-18 10:05:58 #> 23: rda 2019-03-18 10:05:58 #> 24: a71865def6b1292c9213bb755ea4c920 2019-03-18 10:05:58 #> 25: numeric 2019-03-18 10:05:58 #> 26: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 27: 87eee6212ba1ae0a 2019-03-18 10:05:58 #> 28: f 2019-03-18 10:05:58 #> 29: 1104 2019-03-18 10:05:58 #> 30: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 31: saveRDS 2019-03-18 10:05:58 #> 32: do.call 2019-03-18 10:05:58 #> 33: build_site_local 2019-03-18 10:05:58 #> 34: build_reference 2019-03-18 10:05:58 #> 35: data_reference_topic 2019-03-18 10:05:58 #> 36: as_data 2019-03-18 10:05:58 #> 37: as_data.tag_examples 2019-03-18 10:05:58 #> 38: timing_fn 2019-03-18 10:05:58 #> 39: handle 2019-03-18 10:05:58 #> 40: try 2019-03-18 10:05:58 #> 41: withVisible 2019-03-18 10:05:58 #> 42: lapply 2019-03-18 10:05:58 #> 43: n:c5775c3b366fb719 2019-03-18 10:05:58 #> 44: .FUN:4f604aa46882b368 2019-03-18 10:05:58 #> 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: a71865def6b1292c9213bb755ea4c920 format #> 2: a71865def6b1292c9213bb755ea4c920 name #> 3: a71865def6b1292c9213bb755ea4c920 class #> 4: a71865def6b1292c9213bb755ea4c920 date #> 5: a71865def6b1292c9213bb755ea4c920 cacheId #> 6: a71865def6b1292c9213bb755ea4c920 function #> 7: a71865def6b1292c9213bb755ea4c920 object.size #> 8: a71865def6b1292c9213bb755ea4c920 accessed #> 9: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 10: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 11: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 12: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 13: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 14: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 15: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 16: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 17: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 18: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 19: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 20: a71865def6b1292c9213bb755ea4c920 otherFunctions #> 21: a71865def6b1292c9213bb755ea4c920 preDigest #> 22: a71865def6b1292c9213bb755ea4c920 preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2019-03-18 10:05:58 #> 2: a71865def6b1292c9213bb755ea4c920 2019-03-18 10:05:58 #> 3: numeric 2019-03-18 10:05:58 #> 4: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 5: 87eee6212ba1ae0a 2019-03-18 10:05:58 #> 6: f 2019-03-18 10:05:58 #> 7: 1104 2019-03-18 10:05:58 #> 8: 2019-03-18 10:05:58 2019-03-18 10:05:58 #> 9: saveRDS 2019-03-18 10:05:58 #> 10: do.call 2019-03-18 10:05:58 #> 11: build_site_local 2019-03-18 10:05:58 #> 12: build_reference 2019-03-18 10:05:58 #> 13: data_reference_topic 2019-03-18 10:05:58 #> 14: as_data 2019-03-18 10:05:58 #> 15: as_data.tag_examples 2019-03-18 10:05:58 #> 16: timing_fn 2019-03-18 10:05:58 #> 17: handle 2019-03-18 10:05:58 #> 18: try 2019-03-18 10:05:58 #> 19: withVisible 2019-03-18 10:05:58 #> 20: lapply 2019-03-18 10:05:58 #> 21: n:c5775c3b366fb719 2019-03-18 10:05:58 #> 22: .FUN:4f604aa46882b368 2019-03-18 10:05:58 #> tagValue createdDate
# cleanup clearCache(tmpDir, ask = FALSE) unlink(tmpDir, recursive = TRUE)