deprecated

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.

Details

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.

Examples

tmpDir <- file.path(tempdir(), "reproducible_examples", "clearStubArtifacts") lapply(c(runif, rnorm), function(f) { reproducible::Cache(f, 10, cacheRepo = tmpDir) })
#> [[1]] #> [1] 0.08428220 0.43445306 0.81142784 0.21235285 0.74902359 0.82294596 #> [7] 0.89065564 0.01716172 0.95006332 0.16434046 #> attr(,".Cache") #> attr(,".Cache")$newCache #> [1] TRUE #> #> attr(,"tags") #> [1] "cacheId:88dabbb6fbb67941" #> attr(,"call") #> [1] "" #> #> [[2]] #> [1] -0.1829260 -1.3792578 1.2506006 -1.8762368 -0.3687876 -2.1292973 #> [7] 0.3376460 -1.5745748 -0.1963194 0.9150601 #> 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
#> cacheId tagKey tagValue #> 1: 88dabbb6fbb67941 function f #> 2: 88dabbb6fbb67941 class numeric #> 3: 88dabbb6fbb67941 object.size 1104 #> 4: 88dabbb6fbb67941 accessed 2020-08-17 13:07:28 #> 5: 88dabbb6fbb67941 inCloud FALSE #> 6: 88dabbb6fbb67941 resultHash #> 7: 88dabbb6fbb67941 elapsedTimeDigest 0.001999855 secs #> 8: 88dabbb6fbb67941 elapsedTimeFirstRun 0 secs #> 9: 88dabbb6fbb67941 otherFunctions saveRDS #> 10: 88dabbb6fbb67941 otherFunctions do.call #> 11: 88dabbb6fbb67941 otherFunctions build_site_local #> 12: 88dabbb6fbb67941 otherFunctions build_reference #> 13: 88dabbb6fbb67941 otherFunctions data_reference_topic #> 14: 88dabbb6fbb67941 otherFunctions run_examples #> 15: 88dabbb6fbb67941 otherFunctions highlight_examples #> 16: 88dabbb6fbb67941 otherFunctions timing_fn #> 17: 88dabbb6fbb67941 otherFunctions handle #> 18: 88dabbb6fbb67941 otherFunctions try #> 19: 88dabbb6fbb67941 otherFunctions lapply #> 20: 88dabbb6fbb67941 preDigest n:c5775c3b366fb719 #> 21: 88dabbb6fbb67941 preDigest .FUN:881ec847b7161f3c #> 22: 88dabbb6fbb67941 file.size 204 #> 23: 87eee6212ba1ae0a function f #> 24: 87eee6212ba1ae0a class numeric #> 25: 87eee6212ba1ae0a object.size 1104 #> 26: 87eee6212ba1ae0a accessed 2020-08-17 13:07:28 #> 27: 87eee6212ba1ae0a inCloud FALSE #> 28: 87eee6212ba1ae0a resultHash #> 29: 87eee6212ba1ae0a elapsedTimeDigest 0.002505779 secs #> 30: 87eee6212ba1ae0a elapsedTimeFirstRun 0 secs #> 31: 87eee6212ba1ae0a otherFunctions saveRDS #> 32: 87eee6212ba1ae0a otherFunctions do.call #> 33: 87eee6212ba1ae0a otherFunctions build_site_local #> 34: 87eee6212ba1ae0a otherFunctions build_reference #> 35: 87eee6212ba1ae0a otherFunctions data_reference_topic #> 36: 87eee6212ba1ae0a otherFunctions run_examples #> 37: 87eee6212ba1ae0a otherFunctions highlight_examples #> 38: 87eee6212ba1ae0a otherFunctions timing_fn #> 39: 87eee6212ba1ae0a otherFunctions handle #> 40: 87eee6212ba1ae0a otherFunctions try #> 41: 87eee6212ba1ae0a otherFunctions lapply #> 42: 87eee6212ba1ae0a preDigest n:c5775c3b366fb719 #> 43: 87eee6212ba1ae0a preDigest .FUN:4f604aa46882b368 #> 44: 87eee6212ba1ae0a file.size 225 #> cacheId tagKey tagValue #> createdDate #> 1: 2020-08-17 13:07:28 #> 2: 2020-08-17 13:07:28 #> 3: 2020-08-17 13:07:28 #> 4: 2020-08-17 13:07:28 #> 5: 2020-08-17 13:07:28 #> 6: 2020-08-17 13:07:28 #> 7: 2020-08-17 13:07:28 #> 8: 2020-08-17 13:07:28 #> 9: 2020-08-17 13:07:28 #> 10: 2020-08-17 13:07:28 #> 11: 2020-08-17 13:07:28 #> 12: 2020-08-17 13:07:28 #> 13: 2020-08-17 13:07:28 #> 14: 2020-08-17 13:07:28 #> 15: 2020-08-17 13:07:28 #> 16: 2020-08-17 13:07:28 #> 17: 2020-08-17 13:07:28 #> 18: 2020-08-17 13:07:28 #> 19: 2020-08-17 13:07:28 #> 20: 2020-08-17 13:07:28 #> 21: 2020-08-17 13:07:28 #> 22: 2020-08-17 13:07:28 #> 23: 2020-08-17 13:07:28 #> 24: 2020-08-17 13:07:28 #> 25: 2020-08-17 13:07:28 #> 26: 2020-08-17 13:07:28 #> 27: 2020-08-17 13:07:28 #> 28: 2020-08-17 13:07:28 #> 29: 2020-08-17 13:07:28 #> 30: 2020-08-17 13:07:28 #> 31: 2020-08-17 13:07:28 #> 32: 2020-08-17 13:07:28 #> 33: 2020-08-17 13:07:28 #> 34: 2020-08-17 13:07:28 #> 35: 2020-08-17 13:07:28 #> 36: 2020-08-17 13:07:28 #> 37: 2020-08-17 13:07:28 #> 38: 2020-08-17 13:07:28 #> 39: 2020-08-17 13:07:28 #> 40: 2020-08-17 13:07:28 #> 41: 2020-08-17 13:07:28 #> 42: 2020-08-17 13:07:28 #> 43: 2020-08-17 13:07:28 #> 44: 2020-08-17 13:07:28 #> 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: 88dabbb6fbb67941 function f #> 2: 88dabbb6fbb67941 class numeric #> 3: 88dabbb6fbb67941 object.size 1104 #> 4: 88dabbb6fbb67941 accessed 2020-08-17 13:07:28 #> 5: 88dabbb6fbb67941 inCloud FALSE #> 6: 88dabbb6fbb67941 resultHash #> 7: 88dabbb6fbb67941 elapsedTimeDigest 0.001999855 secs #> 8: 88dabbb6fbb67941 elapsedTimeFirstRun 0 secs #> 9: 88dabbb6fbb67941 otherFunctions saveRDS #> 10: 88dabbb6fbb67941 otherFunctions do.call #> 11: 88dabbb6fbb67941 otherFunctions build_site_local #> 12: 88dabbb6fbb67941 otherFunctions build_reference #> 13: 88dabbb6fbb67941 otherFunctions data_reference_topic #> 14: 88dabbb6fbb67941 otherFunctions run_examples #> 15: 88dabbb6fbb67941 otherFunctions highlight_examples #> 16: 88dabbb6fbb67941 otherFunctions timing_fn #> 17: 88dabbb6fbb67941 otherFunctions handle #> 18: 88dabbb6fbb67941 otherFunctions try #> 19: 88dabbb6fbb67941 otherFunctions lapply #> 20: 88dabbb6fbb67941 preDigest n:c5775c3b366fb719 #> 21: 88dabbb6fbb67941 preDigest .FUN:881ec847b7161f3c #> 22: 88dabbb6fbb67941 file.size 204 #> 23: 87eee6212ba1ae0a function f #> 24: 87eee6212ba1ae0a class numeric #> 25: 87eee6212ba1ae0a object.size 1104 #> 26: 87eee6212ba1ae0a accessed 2020-08-17 13:07:28 #> 27: 87eee6212ba1ae0a inCloud FALSE #> 28: 87eee6212ba1ae0a resultHash #> 29: 87eee6212ba1ae0a elapsedTimeDigest 0.002505779 secs #> 30: 87eee6212ba1ae0a elapsedTimeFirstRun 0 secs #> 31: 87eee6212ba1ae0a otherFunctions saveRDS #> 32: 87eee6212ba1ae0a otherFunctions do.call #> 33: 87eee6212ba1ae0a otherFunctions build_site_local #> 34: 87eee6212ba1ae0a otherFunctions build_reference #> 35: 87eee6212ba1ae0a otherFunctions data_reference_topic #> 36: 87eee6212ba1ae0a otherFunctions run_examples #> 37: 87eee6212ba1ae0a otherFunctions highlight_examples #> 38: 87eee6212ba1ae0a otherFunctions timing_fn #> 39: 87eee6212ba1ae0a otherFunctions handle #> 40: 87eee6212ba1ae0a otherFunctions try #> 41: 87eee6212ba1ae0a otherFunctions lapply #> 42: 87eee6212ba1ae0a preDigest n:c5775c3b366fb719 #> 43: 87eee6212ba1ae0a preDigest .FUN:4f604aa46882b368 #> 44: 87eee6212ba1ae0a file.size 225 #> cacheId tagKey tagValue #> createdDate #> 1: 2020-08-17 13:07:28 #> 2: 2020-08-17 13:07:28 #> 3: 2020-08-17 13:07:28 #> 4: 2020-08-17 13:07:28 #> 5: 2020-08-17 13:07:28 #> 6: 2020-08-17 13:07:28 #> 7: 2020-08-17 13:07:28 #> 8: 2020-08-17 13:07:28 #> 9: 2020-08-17 13:07:28 #> 10: 2020-08-17 13:07:28 #> 11: 2020-08-17 13:07:28 #> 12: 2020-08-17 13:07:28 #> 13: 2020-08-17 13:07:28 #> 14: 2020-08-17 13:07:28 #> 15: 2020-08-17 13:07:28 #> 16: 2020-08-17 13:07:28 #> 17: 2020-08-17 13:07:28 #> 18: 2020-08-17 13:07:28 #> 19: 2020-08-17 13:07:28 #> 20: 2020-08-17 13:07:28 #> 21: 2020-08-17 13:07:28 #> 22: 2020-08-17 13:07:28 #> 23: 2020-08-17 13:07:28 #> 24: 2020-08-17 13:07:28 #> 25: 2020-08-17 13:07:28 #> 26: 2020-08-17 13:07:28 #> 27: 2020-08-17 13:07:28 #> 28: 2020-08-17 13:07:28 #> 29: 2020-08-17 13:07:28 #> 30: 2020-08-17 13:07:28 #> 31: 2020-08-17 13:07:28 #> 32: 2020-08-17 13:07:28 #> 33: 2020-08-17 13:07:28 #> 34: 2020-08-17 13:07:28 #> 35: 2020-08-17 13:07:28 #> 36: 2020-08-17 13:07:28 #> 37: 2020-08-17 13:07:28 #> 38: 2020-08-17 13:07:28 #> 39: 2020-08-17 13:07:28 #> 40: 2020-08-17 13:07:28 #> 41: 2020-08-17 13:07:28 #> 42: 2020-08-17 13:07:28 #> 43: 2020-08-17 13:07:28 #> 44: 2020-08-17 13:07:28 #> 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: 88dabbb6fbb67941 function f #> 2: 88dabbb6fbb67941 class numeric #> 3: 88dabbb6fbb67941 object.size 1104 #> 4: 88dabbb6fbb67941 accessed 2020-08-17 13:07:28 #> 5: 88dabbb6fbb67941 inCloud FALSE #> 6: 88dabbb6fbb67941 resultHash #> 7: 88dabbb6fbb67941 elapsedTimeDigest 0.001999855 secs #> 8: 88dabbb6fbb67941 elapsedTimeFirstRun 0 secs #> 9: 88dabbb6fbb67941 otherFunctions saveRDS #> 10: 88dabbb6fbb67941 otherFunctions do.call #> 11: 88dabbb6fbb67941 otherFunctions build_site_local #> 12: 88dabbb6fbb67941 otherFunctions build_reference #> 13: 88dabbb6fbb67941 otherFunctions data_reference_topic #> 14: 88dabbb6fbb67941 otherFunctions run_examples #> 15: 88dabbb6fbb67941 otherFunctions highlight_examples #> 16: 88dabbb6fbb67941 otherFunctions timing_fn #> 17: 88dabbb6fbb67941 otherFunctions handle #> 18: 88dabbb6fbb67941 otherFunctions try #> 19: 88dabbb6fbb67941 otherFunctions lapply #> 20: 88dabbb6fbb67941 preDigest n:c5775c3b366fb719 #> 21: 88dabbb6fbb67941 preDigest .FUN:881ec847b7161f3c #> 22: 88dabbb6fbb67941 file.size 204 #> 23: 87eee6212ba1ae0a function f #> 24: 87eee6212ba1ae0a class numeric #> 25: 87eee6212ba1ae0a object.size 1104 #> 26: 87eee6212ba1ae0a accessed 2020-08-17 13:07:28 #> 27: 87eee6212ba1ae0a inCloud FALSE #> 28: 87eee6212ba1ae0a resultHash #> 29: 87eee6212ba1ae0a elapsedTimeDigest 0.002505779 secs #> 30: 87eee6212ba1ae0a elapsedTimeFirstRun 0 secs #> 31: 87eee6212ba1ae0a otherFunctions saveRDS #> 32: 87eee6212ba1ae0a otherFunctions do.call #> 33: 87eee6212ba1ae0a otherFunctions build_site_local #> 34: 87eee6212ba1ae0a otherFunctions build_reference #> 35: 87eee6212ba1ae0a otherFunctions data_reference_topic #> 36: 87eee6212ba1ae0a otherFunctions run_examples #> 37: 87eee6212ba1ae0a otherFunctions highlight_examples #> 38: 87eee6212ba1ae0a otherFunctions timing_fn #> 39: 87eee6212ba1ae0a otherFunctions handle #> 40: 87eee6212ba1ae0a otherFunctions try #> 41: 87eee6212ba1ae0a otherFunctions lapply #> 42: 87eee6212ba1ae0a preDigest n:c5775c3b366fb719 #> 43: 87eee6212ba1ae0a preDigest .FUN:4f604aa46882b368 #> 44: 87eee6212ba1ae0a file.size 225 #> cacheId tagKey tagValue #> createdDate #> 1: 2020-08-17 13:07:28 #> 2: 2020-08-17 13:07:28 #> 3: 2020-08-17 13:07:28 #> 4: 2020-08-17 13:07:28 #> 5: 2020-08-17 13:07:28 #> 6: 2020-08-17 13:07:28 #> 7: 2020-08-17 13:07:28 #> 8: 2020-08-17 13:07:28 #> 9: 2020-08-17 13:07:28 #> 10: 2020-08-17 13:07:28 #> 11: 2020-08-17 13:07:28 #> 12: 2020-08-17 13:07:28 #> 13: 2020-08-17 13:07:28 #> 14: 2020-08-17 13:07:28 #> 15: 2020-08-17 13:07:28 #> 16: 2020-08-17 13:07:28 #> 17: 2020-08-17 13:07:28 #> 18: 2020-08-17 13:07:28 #> 19: 2020-08-17 13:07:28 #> 20: 2020-08-17 13:07:28 #> 21: 2020-08-17 13:07:28 #> 22: 2020-08-17 13:07:28 #> 23: 2020-08-17 13:07:28 #> 24: 2020-08-17 13:07:28 #> 25: 2020-08-17 13:07:28 #> 26: 2020-08-17 13:07:28 #> 27: 2020-08-17 13:07:28 #> 28: 2020-08-17 13:07:28 #> 29: 2020-08-17 13:07:28 #> 30: 2020-08-17 13:07:28 #> 31: 2020-08-17 13:07:28 #> 32: 2020-08-17 13:07:28 #> 33: 2020-08-17 13:07:28 #> 34: 2020-08-17 13:07:28 #> 35: 2020-08-17 13:07:28 #> 36: 2020-08-17 13:07:28 #> 37: 2020-08-17 13:07:28 #> 38: 2020-08-17 13:07:28 #> 39: 2020-08-17 13:07:28 #> 40: 2020-08-17 13:07:28 #> 41: 2020-08-17 13:07:28 #> 42: 2020-08-17 13:07:28 #> 43: 2020-08-17 13:07:28 #> 44: 2020-08-17 13:07:28 #> createdDate
# cleanup clearCache(tmpDir, ask = FALSE) unlink(tmpDir, recursive = TRUE)