clearStubArtifacts(repoDir = NULL)
# S4 method for ANY
clearStubArtifacts(repoDir = NULL)
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
.
Invoked for its side effect on the repoDir
.
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.
data.table::setDTthreads(2)
tmpDir <- file.path(tempdir(), "reproducible_examples", "clearStubArtifacts")
lapply(c(runif, rnorm), function(f) {
reproducible::Cache(f, 10, cachePath = tmpDir)
})
#> [[1]]
#> [1] 0.18259237 0.08306840 0.22754277 0.27831834 0.17790227 0.03377688
#> [7] 0.30335405 0.08526241 0.39190454 0.58961253
#> attr(,".Cache")
#> attr(,".Cache")$newCache
#> [1] TRUE
#>
#> attr(,"tags")
#> [1] "cacheId:98b52ff8fc0f4d2c"
#> attr(,"call")
#> [1] ""
#>
#> [[2]]
#> [1] 1.3785236 1.1434616 -0.3630613 1.4680553 0.7277229 -1.7300545
#> [7] -0.7522926 -1.3754259 -1.1667812 -0.1251576
#> attr(,".Cache")
#> attr(,".Cache")$newCache
#> [1] TRUE
#>
#> attr(,"tags")
#> [1] "cacheId:76428544f5e765a5"
#> attr(,"call")
#> [1] ""
#>
# clear out any stub artifacts
showCache(tmpDir)
#> Cache size:
#> Total (including Rasters): 552 bytes
#> Selected objects (not including Rasters): 552 bytes
#> cacheId tagKey tagValue
#> 1: 76428544f5e765a5 function f
#> 2: 76428544f5e765a5 class numeric
#> 3: 76428544f5e765a5 object.size 1104
#> 4: 76428544f5e765a5 accessed 2022-12-23 01:51:11
#> 5: 76428544f5e765a5 inCloud FALSE
#> 6: 76428544f5e765a5 resultHash
#> 7: 76428544f5e765a5 elapsedTimeDigest 0.002283812 secs
#> 8: 76428544f5e765a5 elapsedTimeFirstRun 2.43187e-05 secs
#> 9: 76428544f5e765a5 otherFunctions build_site
#> 10: 76428544f5e765a5 otherFunctions build_site_local
#> 11: 76428544f5e765a5 otherFunctions build_reference
#> 12: 76428544f5e765a5 otherFunctions map_
#> 13: 76428544f5e765a5 otherFunctions with_indexed_errors
#> 14: 76428544f5e765a5 otherFunctions data_reference_topic
#> 15: 76428544f5e765a5 otherFunctions run_examples
#> 16: 76428544f5e765a5 otherFunctions highlight_examples
#> 17: 76428544f5e765a5 otherFunctions timing_fn
#> 18: 76428544f5e765a5 otherFunctions handle
#> 19: 76428544f5e765a5 otherFunctions try
#> 20: 76428544f5e765a5 otherFunctions lapply
#> 21: 76428544f5e765a5 preDigest n:c5775c3b366fb719
#> 22: 76428544f5e765a5 preDigest mean:c40c00762a0dac94
#> 23: 76428544f5e765a5 preDigest sd:853b1797f54b229c
#> 24: 76428544f5e765a5 preDigest .FUN:4f604aa46882b368
#> 25: 76428544f5e765a5 file.size 225
#> 26: 98b52ff8fc0f4d2c function f
#> 27: 98b52ff8fc0f4d2c class numeric
#> 28: 98b52ff8fc0f4d2c object.size 1104
#> 29: 98b52ff8fc0f4d2c accessed 2022-12-23 01:51:11
#> 30: 98b52ff8fc0f4d2c inCloud FALSE
#> 31: 98b52ff8fc0f4d2c resultHash
#> 32: 98b52ff8fc0f4d2c elapsedTimeDigest 0.002538204 secs
#> 33: 98b52ff8fc0f4d2c elapsedTimeFirstRun 2.384186e-05 secs
#> 34: 98b52ff8fc0f4d2c otherFunctions build_site
#> 35: 98b52ff8fc0f4d2c otherFunctions build_site_local
#> 36: 98b52ff8fc0f4d2c otherFunctions build_reference
#> 37: 98b52ff8fc0f4d2c otherFunctions map_
#> 38: 98b52ff8fc0f4d2c otherFunctions with_indexed_errors
#> 39: 98b52ff8fc0f4d2c otherFunctions data_reference_topic
#> 40: 98b52ff8fc0f4d2c otherFunctions run_examples
#> 41: 98b52ff8fc0f4d2c otherFunctions highlight_examples
#> 42: 98b52ff8fc0f4d2c otherFunctions timing_fn
#> 43: 98b52ff8fc0f4d2c otherFunctions handle
#> 44: 98b52ff8fc0f4d2c otherFunctions try
#> 45: 98b52ff8fc0f4d2c otherFunctions lapply
#> 46: 98b52ff8fc0f4d2c preDigest n:c5775c3b366fb719
#> 47: 98b52ff8fc0f4d2c preDigest min:c40c00762a0dac94
#> 48: 98b52ff8fc0f4d2c preDigest max:853b1797f54b229c
#> 49: 98b52ff8fc0f4d2c preDigest .FUN:881ec847b7161f3c
#> 50: 98b52ff8fc0f4d2c file.size 206
#> cacheId tagKey tagValue
#> createdDate
#> 1: 2022-12-23 01:51:11
#> 2: 2022-12-23 01:51:11
#> 3: 2022-12-23 01:51:11
#> 4: 2022-12-23 01:51:11
#> 5: 2022-12-23 01:51:11
#> 6: 2022-12-23 01:51:11
#> 7: 2022-12-23 01:51:11
#> 8: 2022-12-23 01:51:11
#> 9: 2022-12-23 01:51:11
#> 10: 2022-12-23 01:51:11
#> 11: 2022-12-23 01:51:11
#> 12: 2022-12-23 01:51:11
#> 13: 2022-12-23 01:51:11
#> 14: 2022-12-23 01:51:11
#> 15: 2022-12-23 01:51:11
#> 16: 2022-12-23 01:51:11
#> 17: 2022-12-23 01:51:11
#> 18: 2022-12-23 01:51:11
#> 19: 2022-12-23 01:51:11
#> 20: 2022-12-23 01:51:11
#> 21: 2022-12-23 01:51:11
#> 22: 2022-12-23 01:51:11
#> 23: 2022-12-23 01:51:11
#> 24: 2022-12-23 01:51:11
#> 25: 2022-12-23 01:51:11
#> 26: 2022-12-23 01:51:11
#> 27: 2022-12-23 01:51:11
#> 28: 2022-12-23 01:51:11
#> 29: 2022-12-23 01:51:11
#> 30: 2022-12-23 01:51:11
#> 31: 2022-12-23 01:51:11
#> 32: 2022-12-23 01:51:11
#> 33: 2022-12-23 01:51:11
#> 34: 2022-12-23 01:51:11
#> 35: 2022-12-23 01:51:11
#> 36: 2022-12-23 01:51:11
#> 37: 2022-12-23 01:51:11
#> 38: 2022-12-23 01:51:11
#> 39: 2022-12-23 01:51:11
#> 40: 2022-12-23 01:51:11
#> 41: 2022-12-23 01:51:11
#> 42: 2022-12-23 01:51:11
#> 43: 2022-12-23 01:51:11
#> 44: 2022-12-23 01:51:11
#> 45: 2022-12-23 01:51:11
#> 46: 2022-12-23 01:51:11
#> 47: 2022-12-23 01:51:11
#> 48: 2022-12-23 01:51:11
#> 49: 2022-12-23 01:51:11
#> 50: 2022-12-23 01:51:11
#> createdDate
file2Remove <- dir(CacheStorageDir(tmpDir), 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
#> cacheId tagKey tagValue
#> 1: 76428544f5e765a5 function f
#> 2: 76428544f5e765a5 class numeric
#> 3: 76428544f5e765a5 object.size 1104
#> 4: 76428544f5e765a5 accessed 2022-12-23 01:51:11
#> 5: 76428544f5e765a5 inCloud FALSE
#> 6: 76428544f5e765a5 resultHash
#> 7: 76428544f5e765a5 elapsedTimeDigest 0.002283812 secs
#> 8: 76428544f5e765a5 elapsedTimeFirstRun 2.43187e-05 secs
#> 9: 76428544f5e765a5 otherFunctions build_site
#> 10: 76428544f5e765a5 otherFunctions build_site_local
#> 11: 76428544f5e765a5 otherFunctions build_reference
#> 12: 76428544f5e765a5 otherFunctions map_
#> 13: 76428544f5e765a5 otherFunctions with_indexed_errors
#> 14: 76428544f5e765a5 otherFunctions data_reference_topic
#> 15: 76428544f5e765a5 otherFunctions run_examples
#> 16: 76428544f5e765a5 otherFunctions highlight_examples
#> 17: 76428544f5e765a5 otherFunctions timing_fn
#> 18: 76428544f5e765a5 otherFunctions handle
#> 19: 76428544f5e765a5 otherFunctions try
#> 20: 76428544f5e765a5 otherFunctions lapply
#> 21: 76428544f5e765a5 preDigest n:c5775c3b366fb719
#> 22: 76428544f5e765a5 preDigest mean:c40c00762a0dac94
#> 23: 76428544f5e765a5 preDigest sd:853b1797f54b229c
#> 24: 76428544f5e765a5 preDigest .FUN:4f604aa46882b368
#> 25: 76428544f5e765a5 file.size 225
#> 26: 98b52ff8fc0f4d2c function f
#> 27: 98b52ff8fc0f4d2c class numeric
#> 28: 98b52ff8fc0f4d2c object.size 1104
#> 29: 98b52ff8fc0f4d2c accessed 2022-12-23 01:51:11
#> 30: 98b52ff8fc0f4d2c inCloud FALSE
#> 31: 98b52ff8fc0f4d2c resultHash
#> 32: 98b52ff8fc0f4d2c elapsedTimeDigest 0.002538204 secs
#> 33: 98b52ff8fc0f4d2c elapsedTimeFirstRun 2.384186e-05 secs
#> 34: 98b52ff8fc0f4d2c otherFunctions build_site
#> 35: 98b52ff8fc0f4d2c otherFunctions build_site_local
#> 36: 98b52ff8fc0f4d2c otherFunctions build_reference
#> 37: 98b52ff8fc0f4d2c otherFunctions map_
#> 38: 98b52ff8fc0f4d2c otherFunctions with_indexed_errors
#> 39: 98b52ff8fc0f4d2c otherFunctions data_reference_topic
#> 40: 98b52ff8fc0f4d2c otherFunctions run_examples
#> 41: 98b52ff8fc0f4d2c otherFunctions highlight_examples
#> 42: 98b52ff8fc0f4d2c otherFunctions timing_fn
#> 43: 98b52ff8fc0f4d2c otherFunctions handle
#> 44: 98b52ff8fc0f4d2c otherFunctions try
#> 45: 98b52ff8fc0f4d2c otherFunctions lapply
#> 46: 98b52ff8fc0f4d2c preDigest n:c5775c3b366fb719
#> 47: 98b52ff8fc0f4d2c preDigest min:c40c00762a0dac94
#> 48: 98b52ff8fc0f4d2c preDigest max:853b1797f54b229c
#> 49: 98b52ff8fc0f4d2c preDigest .FUN:881ec847b7161f3c
#> 50: 98b52ff8fc0f4d2c file.size 206
#> cacheId tagKey tagValue
#> createdDate
#> 1: 2022-12-23 01:51:11
#> 2: 2022-12-23 01:51:11
#> 3: 2022-12-23 01:51:11
#> 4: 2022-12-23 01:51:11
#> 5: 2022-12-23 01:51:11
#> 6: 2022-12-23 01:51:11
#> 7: 2022-12-23 01:51:11
#> 8: 2022-12-23 01:51:11
#> 9: 2022-12-23 01:51:11
#> 10: 2022-12-23 01:51:11
#> 11: 2022-12-23 01:51:11
#> 12: 2022-12-23 01:51:11
#> 13: 2022-12-23 01:51:11
#> 14: 2022-12-23 01:51:11
#> 15: 2022-12-23 01:51:11
#> 16: 2022-12-23 01:51:11
#> 17: 2022-12-23 01:51:11
#> 18: 2022-12-23 01:51:11
#> 19: 2022-12-23 01:51:11
#> 20: 2022-12-23 01:51:11
#> 21: 2022-12-23 01:51:11
#> 22: 2022-12-23 01:51:11
#> 23: 2022-12-23 01:51:11
#> 24: 2022-12-23 01:51:11
#> 25: 2022-12-23 01:51:11
#> 26: 2022-12-23 01:51:11
#> 27: 2022-12-23 01:51:11
#> 28: 2022-12-23 01:51:11
#> 29: 2022-12-23 01:51:11
#> 30: 2022-12-23 01:51:11
#> 31: 2022-12-23 01:51:11
#> 32: 2022-12-23 01:51:11
#> 33: 2022-12-23 01:51:11
#> 34: 2022-12-23 01:51:11
#> 35: 2022-12-23 01:51:11
#> 36: 2022-12-23 01:51:11
#> 37: 2022-12-23 01:51:11
#> 38: 2022-12-23 01:51:11
#> 39: 2022-12-23 01:51:11
#> 40: 2022-12-23 01:51:11
#> 41: 2022-12-23 01:51:11
#> 42: 2022-12-23 01:51:11
#> 43: 2022-12-23 01:51:11
#> 44: 2022-12-23 01:51:11
#> 45: 2022-12-23 01:51:11
#> 46: 2022-12-23 01:51:11
#> 47: 2022-12-23 01:51:11
#> 48: 2022-12-23 01:51:11
#> 49: 2022-12-23 01:51:11
#> 50: 2022-12-23 01:51:11
#> createdDate
# run clearStubArtifacts
suppressWarnings(clearStubArtifacts(tmpDir))
showCache(tmpDir) # stubs are removed
#> Cache size:
#> Total (including Rasters): 552 bytes
#> Selected objects (not including Rasters): 552 bytes
#> cacheId tagKey tagValue
#> 1: 76428544f5e765a5 function f
#> 2: 76428544f5e765a5 class numeric
#> 3: 76428544f5e765a5 object.size 1104
#> 4: 76428544f5e765a5 accessed 2022-12-23 01:51:11
#> 5: 76428544f5e765a5 inCloud FALSE
#> 6: 76428544f5e765a5 resultHash
#> 7: 76428544f5e765a5 elapsedTimeDigest 0.002283812 secs
#> 8: 76428544f5e765a5 elapsedTimeFirstRun 2.43187e-05 secs
#> 9: 76428544f5e765a5 otherFunctions build_site
#> 10: 76428544f5e765a5 otherFunctions build_site_local
#> 11: 76428544f5e765a5 otherFunctions build_reference
#> 12: 76428544f5e765a5 otherFunctions map_
#> 13: 76428544f5e765a5 otherFunctions with_indexed_errors
#> 14: 76428544f5e765a5 otherFunctions data_reference_topic
#> 15: 76428544f5e765a5 otherFunctions run_examples
#> 16: 76428544f5e765a5 otherFunctions highlight_examples
#> 17: 76428544f5e765a5 otherFunctions timing_fn
#> 18: 76428544f5e765a5 otherFunctions handle
#> 19: 76428544f5e765a5 otherFunctions try
#> 20: 76428544f5e765a5 otherFunctions lapply
#> 21: 76428544f5e765a5 preDigest n:c5775c3b366fb719
#> 22: 76428544f5e765a5 preDigest mean:c40c00762a0dac94
#> 23: 76428544f5e765a5 preDigest sd:853b1797f54b229c
#> 24: 76428544f5e765a5 preDigest .FUN:4f604aa46882b368
#> 25: 76428544f5e765a5 file.size 225
#> 26: 98b52ff8fc0f4d2c function f
#> 27: 98b52ff8fc0f4d2c class numeric
#> 28: 98b52ff8fc0f4d2c object.size 1104
#> 29: 98b52ff8fc0f4d2c accessed 2022-12-23 01:51:11
#> 30: 98b52ff8fc0f4d2c inCloud FALSE
#> 31: 98b52ff8fc0f4d2c resultHash
#> 32: 98b52ff8fc0f4d2c elapsedTimeDigest 0.002538204 secs
#> 33: 98b52ff8fc0f4d2c elapsedTimeFirstRun 2.384186e-05 secs
#> 34: 98b52ff8fc0f4d2c otherFunctions build_site
#> 35: 98b52ff8fc0f4d2c otherFunctions build_site_local
#> 36: 98b52ff8fc0f4d2c otherFunctions build_reference
#> 37: 98b52ff8fc0f4d2c otherFunctions map_
#> 38: 98b52ff8fc0f4d2c otherFunctions with_indexed_errors
#> 39: 98b52ff8fc0f4d2c otherFunctions data_reference_topic
#> 40: 98b52ff8fc0f4d2c otherFunctions run_examples
#> 41: 98b52ff8fc0f4d2c otherFunctions highlight_examples
#> 42: 98b52ff8fc0f4d2c otherFunctions timing_fn
#> 43: 98b52ff8fc0f4d2c otherFunctions handle
#> 44: 98b52ff8fc0f4d2c otherFunctions try
#> 45: 98b52ff8fc0f4d2c otherFunctions lapply
#> 46: 98b52ff8fc0f4d2c preDigest n:c5775c3b366fb719
#> 47: 98b52ff8fc0f4d2c preDigest min:c40c00762a0dac94
#> 48: 98b52ff8fc0f4d2c preDigest max:853b1797f54b229c
#> 49: 98b52ff8fc0f4d2c preDigest .FUN:881ec847b7161f3c
#> 50: 98b52ff8fc0f4d2c file.size 206
#> cacheId tagKey tagValue
#> createdDate
#> 1: 2022-12-23 01:51:11
#> 2: 2022-12-23 01:51:11
#> 3: 2022-12-23 01:51:11
#> 4: 2022-12-23 01:51:11
#> 5: 2022-12-23 01:51:11
#> 6: 2022-12-23 01:51:11
#> 7: 2022-12-23 01:51:11
#> 8: 2022-12-23 01:51:11
#> 9: 2022-12-23 01:51:11
#> 10: 2022-12-23 01:51:11
#> 11: 2022-12-23 01:51:11
#> 12: 2022-12-23 01:51:11
#> 13: 2022-12-23 01:51:11
#> 14: 2022-12-23 01:51:11
#> 15: 2022-12-23 01:51:11
#> 16: 2022-12-23 01:51:11
#> 17: 2022-12-23 01:51:11
#> 18: 2022-12-23 01:51:11
#> 19: 2022-12-23 01:51:11
#> 20: 2022-12-23 01:51:11
#> 21: 2022-12-23 01:51:11
#> 22: 2022-12-23 01:51:11
#> 23: 2022-12-23 01:51:11
#> 24: 2022-12-23 01:51:11
#> 25: 2022-12-23 01:51:11
#> 26: 2022-12-23 01:51:11
#> 27: 2022-12-23 01:51:11
#> 28: 2022-12-23 01:51:11
#> 29: 2022-12-23 01:51:11
#> 30: 2022-12-23 01:51:11
#> 31: 2022-12-23 01:51:11
#> 32: 2022-12-23 01:51:11
#> 33: 2022-12-23 01:51:11
#> 34: 2022-12-23 01:51:11
#> 35: 2022-12-23 01:51:11
#> 36: 2022-12-23 01:51:11
#> 37: 2022-12-23 01:51:11
#> 38: 2022-12-23 01:51:11
#> 39: 2022-12-23 01:51:11
#> 40: 2022-12-23 01:51:11
#> 41: 2022-12-23 01:51:11
#> 42: 2022-12-23 01:51:11
#> 43: 2022-12-23 01:51:11
#> 44: 2022-12-23 01:51:11
#> 45: 2022-12-23 01:51:11
#> 46: 2022-12-23 01:51:11
#> 47: 2022-12-23 01:51:11
#> 48: 2022-12-23 01:51:11
#> 49: 2022-12-23 01:51:11
#> 50: 2022-12-23 01:51:11
#> createdDate
# cleanup
clearCache(tmpDir, ask = FALSE)
unlink(tmpDir, recursive = TRUE)