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