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(,"tags") #> [1] "cacheId:c544d867e89c93fb20f0fccb922cc028" #> attr(,".Cache") #> attr(,".Cache")$newCache #> [1] TRUE #> #> 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(,"tags") #> [1] "cacheId:03dcbe8e18b571c397bbc2e72230d216" #> attr(,".Cache") #> attr(,".Cache")$newCache #> [1] TRUE #> #> attr(,"call") #> [1] "" #>
# clear out any stub artifacts showCache(tmpDir)
#> Cache size:
#> Total (including Rasters): 560 bytes
#> Selected objects (not including Rasters): 560 bytes
#> artifact tagKey #> 1: 0775377bdf0e2f316b7c3587fe05f4bc format #> 2: 0775377bdf0e2f316b7c3587fe05f4bc name #> 3: 0775377bdf0e2f316b7c3587fe05f4bc class #> 4: 0775377bdf0e2f316b7c3587fe05f4bc date #> 5: 0775377bdf0e2f316b7c3587fe05f4bc cacheId #> 6: 0775377bdf0e2f316b7c3587fe05f4bc function #> 7: 0775377bdf0e2f316b7c3587fe05f4bc object.size #> 8: 0775377bdf0e2f316b7c3587fe05f4bc accessed #> 9: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 10: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 11: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 12: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 13: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 14: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 15: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 16: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 17: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 18: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 19: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 20: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 21: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 22: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 23: 0775377bdf0e2f316b7c3587fe05f4bc preDigest #> 24: 0775377bdf0e2f316b7c3587fe05f4bc preDigest #> 25: 5bfc07af9f3dbb0b111e043425c3bfaf format #> 26: 5bfc07af9f3dbb0b111e043425c3bfaf name #> 27: 5bfc07af9f3dbb0b111e043425c3bfaf class #> 28: 5bfc07af9f3dbb0b111e043425c3bfaf date #> 29: 5bfc07af9f3dbb0b111e043425c3bfaf cacheId #> 30: 5bfc07af9f3dbb0b111e043425c3bfaf function #> 31: 5bfc07af9f3dbb0b111e043425c3bfaf object.size #> 32: 5bfc07af9f3dbb0b111e043425c3bfaf accessed #> 33: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 34: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 35: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 36: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 37: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 38: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 39: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 40: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 41: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 42: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 43: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 44: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 45: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 46: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 47: 5bfc07af9f3dbb0b111e043425c3bfaf preDigest #> 48: 5bfc07af9f3dbb0b111e043425c3bfaf preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2018-11-09 08:47:02 #> 2: 0775377bdf0e2f316b7c3587fe05f4bc 2018-11-09 08:47:02 #> 3: numeric 2018-11-09 08:47:02 #> 4: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 5: c544d867e89c93fb20f0fccb922cc028 2018-11-09 08:47:02 #> 6: f 2018-11-09 08:47:02 #> 7: 1120 2018-11-09 08:47:02 #> 8: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 9: withCallingHandlers 2018-11-09 08:47:02 #> 10: saveRDS 2018-11-09 08:47:02 #> 11: do.call 2018-11-09 08:47:02 #> 12: build_site_local 2018-11-09 08:47:02 #> 13: build_reference 2018-11-09 08:47:02 #> 14: data_reference_topic 2018-11-09 08:47:02 #> 15: as_data 2018-11-09 08:47:02 #> 16: as_data.tag_examples 2018-11-09 08:47:02 #> 17: timing_fn 2018-11-09 08:47:02 #> 18: handle 2018-11-09 08:47:02 #> 19: try 2018-11-09 08:47:02 #> 20: withVisible 2018-11-09 08:47:02 #> 21: lapply 2018-11-09 08:47:02 #> 22: FUN 2018-11-09 08:47:02 #> 23: n:c192d58bc0a9ddf2b5f916d929bccc08 2018-11-09 08:47:02 #> 24: .FUN:179092fbad3ec261e58bc89bc8a703c3 2018-11-09 08:47:02 #> 25: rda 2018-11-09 08:47:02 #> 26: 5bfc07af9f3dbb0b111e043425c3bfaf 2018-11-09 08:47:02 #> 27: numeric 2018-11-09 08:47:02 #> 28: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 29: 03dcbe8e18b571c397bbc2e72230d216 2018-11-09 08:47:02 #> 30: f 2018-11-09 08:47:02 #> 31: 1120 2018-11-09 08:47:02 #> 32: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 33: withCallingHandlers 2018-11-09 08:47:02 #> 34: saveRDS 2018-11-09 08:47:02 #> 35: do.call 2018-11-09 08:47:02 #> 36: build_site_local 2018-11-09 08:47:02 #> 37: build_reference 2018-11-09 08:47:02 #> 38: data_reference_topic 2018-11-09 08:47:02 #> 39: as_data 2018-11-09 08:47:02 #> 40: as_data.tag_examples 2018-11-09 08:47:02 #> 41: timing_fn 2018-11-09 08:47:02 #> 42: handle 2018-11-09 08:47:02 #> 43: try 2018-11-09 08:47:02 #> 44: withVisible 2018-11-09 08:47:02 #> 45: lapply 2018-11-09 08:47:02 #> 46: FUN 2018-11-09 08:47:02 #> 47: n:c192d58bc0a9ddf2b5f916d929bccc08 2018-11-09 08:47:02 #> 48: .FUN:a979d0700a6ef8c7c18736096ff1d522 2018-11-09 08:47:02 #> 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): 560 bytes
#> Selected objects (not including Rasters): 560 bytes
#> artifact tagKey #> 1: 0775377bdf0e2f316b7c3587fe05f4bc format #> 2: 0775377bdf0e2f316b7c3587fe05f4bc name #> 3: 0775377bdf0e2f316b7c3587fe05f4bc class #> 4: 0775377bdf0e2f316b7c3587fe05f4bc date #> 5: 0775377bdf0e2f316b7c3587fe05f4bc cacheId #> 6: 0775377bdf0e2f316b7c3587fe05f4bc function #> 7: 0775377bdf0e2f316b7c3587fe05f4bc object.size #> 8: 0775377bdf0e2f316b7c3587fe05f4bc accessed #> 9: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 10: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 11: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 12: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 13: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 14: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 15: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 16: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 17: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 18: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 19: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 20: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 21: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 22: 0775377bdf0e2f316b7c3587fe05f4bc otherFunctions #> 23: 0775377bdf0e2f316b7c3587fe05f4bc preDigest #> 24: 0775377bdf0e2f316b7c3587fe05f4bc preDigest #> 25: 5bfc07af9f3dbb0b111e043425c3bfaf format #> 26: 5bfc07af9f3dbb0b111e043425c3bfaf name #> 27: 5bfc07af9f3dbb0b111e043425c3bfaf class #> 28: 5bfc07af9f3dbb0b111e043425c3bfaf date #> 29: 5bfc07af9f3dbb0b111e043425c3bfaf cacheId #> 30: 5bfc07af9f3dbb0b111e043425c3bfaf function #> 31: 5bfc07af9f3dbb0b111e043425c3bfaf object.size #> 32: 5bfc07af9f3dbb0b111e043425c3bfaf accessed #> 33: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 34: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 35: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 36: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 37: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 38: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 39: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 40: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 41: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 42: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 43: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 44: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 45: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 46: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 47: 5bfc07af9f3dbb0b111e043425c3bfaf preDigest #> 48: 5bfc07af9f3dbb0b111e043425c3bfaf preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2018-11-09 08:47:02 #> 2: 0775377bdf0e2f316b7c3587fe05f4bc 2018-11-09 08:47:02 #> 3: numeric 2018-11-09 08:47:02 #> 4: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 5: c544d867e89c93fb20f0fccb922cc028 2018-11-09 08:47:02 #> 6: f 2018-11-09 08:47:02 #> 7: 1120 2018-11-09 08:47:02 #> 8: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 9: withCallingHandlers 2018-11-09 08:47:02 #> 10: saveRDS 2018-11-09 08:47:02 #> 11: do.call 2018-11-09 08:47:02 #> 12: build_site_local 2018-11-09 08:47:02 #> 13: build_reference 2018-11-09 08:47:02 #> 14: data_reference_topic 2018-11-09 08:47:02 #> 15: as_data 2018-11-09 08:47:02 #> 16: as_data.tag_examples 2018-11-09 08:47:02 #> 17: timing_fn 2018-11-09 08:47:02 #> 18: handle 2018-11-09 08:47:02 #> 19: try 2018-11-09 08:47:02 #> 20: withVisible 2018-11-09 08:47:02 #> 21: lapply 2018-11-09 08:47:02 #> 22: FUN 2018-11-09 08:47:02 #> 23: n:c192d58bc0a9ddf2b5f916d929bccc08 2018-11-09 08:47:02 #> 24: .FUN:179092fbad3ec261e58bc89bc8a703c3 2018-11-09 08:47:02 #> 25: rda 2018-11-09 08:47:02 #> 26: 5bfc07af9f3dbb0b111e043425c3bfaf 2018-11-09 08:47:02 #> 27: numeric 2018-11-09 08:47:02 #> 28: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 29: 03dcbe8e18b571c397bbc2e72230d216 2018-11-09 08:47:02 #> 30: f 2018-11-09 08:47:02 #> 31: 1120 2018-11-09 08:47:02 #> 32: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 33: withCallingHandlers 2018-11-09 08:47:02 #> 34: saveRDS 2018-11-09 08:47:02 #> 35: do.call 2018-11-09 08:47:02 #> 36: build_site_local 2018-11-09 08:47:02 #> 37: build_reference 2018-11-09 08:47:02 #> 38: data_reference_topic 2018-11-09 08:47:02 #> 39: as_data 2018-11-09 08:47:02 #> 40: as_data.tag_examples 2018-11-09 08:47:02 #> 41: timing_fn 2018-11-09 08:47:02 #> 42: handle 2018-11-09 08:47:02 #> 43: try 2018-11-09 08:47:02 #> 44: withVisible 2018-11-09 08:47:02 #> 45: lapply 2018-11-09 08:47:02 #> 46: FUN 2018-11-09 08:47:02 #> 47: n:c192d58bc0a9ddf2b5f916d929bccc08 2018-11-09 08:47:02 #> 48: .FUN:a979d0700a6ef8c7c18736096ff1d522 2018-11-09 08:47:02 #> tagValue createdDate
# run clearStubArtifacts suppressWarnings(clearStubArtifacts(tmpDir)) showCache(tmpDir) # stubs are removed
#> Cache size:
#> Total (including Rasters): 280 bytes
#> Selected objects (not including Rasters): 280 bytes
#> artifact tagKey #> 1: 5bfc07af9f3dbb0b111e043425c3bfaf format #> 2: 5bfc07af9f3dbb0b111e043425c3bfaf name #> 3: 5bfc07af9f3dbb0b111e043425c3bfaf class #> 4: 5bfc07af9f3dbb0b111e043425c3bfaf date #> 5: 5bfc07af9f3dbb0b111e043425c3bfaf cacheId #> 6: 5bfc07af9f3dbb0b111e043425c3bfaf function #> 7: 5bfc07af9f3dbb0b111e043425c3bfaf object.size #> 8: 5bfc07af9f3dbb0b111e043425c3bfaf accessed #> 9: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 10: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 11: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 12: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 13: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 14: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 15: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 16: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 17: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 18: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 19: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 20: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 21: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 22: 5bfc07af9f3dbb0b111e043425c3bfaf otherFunctions #> 23: 5bfc07af9f3dbb0b111e043425c3bfaf preDigest #> 24: 5bfc07af9f3dbb0b111e043425c3bfaf preDigest #> artifact tagKey #> tagValue createdDate #> 1: rda 2018-11-09 08:47:02 #> 2: 5bfc07af9f3dbb0b111e043425c3bfaf 2018-11-09 08:47:02 #> 3: numeric 2018-11-09 08:47:02 #> 4: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 5: 03dcbe8e18b571c397bbc2e72230d216 2018-11-09 08:47:02 #> 6: f 2018-11-09 08:47:02 #> 7: 1120 2018-11-09 08:47:02 #> 8: 2018-11-09 08:47:02 2018-11-09 08:47:02 #> 9: withCallingHandlers 2018-11-09 08:47:02 #> 10: saveRDS 2018-11-09 08:47:02 #> 11: do.call 2018-11-09 08:47:02 #> 12: build_site_local 2018-11-09 08:47:02 #> 13: build_reference 2018-11-09 08:47:02 #> 14: data_reference_topic 2018-11-09 08:47:02 #> 15: as_data 2018-11-09 08:47:02 #> 16: as_data.tag_examples 2018-11-09 08:47:02 #> 17: timing_fn 2018-11-09 08:47:02 #> 18: handle 2018-11-09 08:47:02 #> 19: try 2018-11-09 08:47:02 #> 20: withVisible 2018-11-09 08:47:02 #> 21: lapply 2018-11-09 08:47:02 #> 22: FUN 2018-11-09 08:47:02 #> 23: n:c192d58bc0a9ddf2b5f916d929bccc08 2018-11-09 08:47:02 #> 24: .FUN:a979d0700a6ef8c7c18736096ff1d522 2018-11-09 08:47:02 #> tagValue createdDate
# cleanup clearCache(tmpDir) unlink(tmpDir, recursive = TRUE)