Skip to contents

Describes what the cache directory holds: which archive snapshots have been listed, and for every force-month file in them whether its content is available locally, either because it was fetched by lamp_archive_download() or because the whole zip was registered with lamp_archive_register(). The snapshot is the starting point for lamp_list_versions() and the readers.

Usage

lamp_archive_snapshot(dir = lamp_cache_dir())

Arguments

dir

Cache directory; see lamp_cache_dir().

Value

A list of class lamp_snapshot with elements dir, archives (one row per archive: archive, source, kind, size, etag, last_modified, md5, n_members, listed_at) and members (one row per file: archive, member, month, force_id, file_type, crc32, csize, usize, available, path, sha256, fetched_at).

Examples

cache <- tempfile("streetlamp-cache-")
zips <- list.files(
  system.file("extdata", "archive", package = "streetlamp"),
  pattern = "zip$", full.names = TRUE
)
for (z in zips) lamp_archive_register(z, dir = cache)
#> Registered archive "2026-06" from
#> /home/runner/work/_temp/Library/streetlamp/extdata/archive/2026-06.zip.
#> Registered archive "2026-07" from
#> /home/runner/work/_temp/Library/streetlamp/extdata/archive/2026-07.zip.
snap <- lamp_archive_snapshot(cache)
snap
#> 
#> ── streetlamp archive snapshot 
#> Cache: /tmp/RtmpjpgtJA/streetlamp-cache-1cb01d43351c
#> 2 archives: "2026-06" and "2026-07"
#> 25 force-month files covering 2 forces, 2026-05 to 2026-07; 25 available
#> locally.
#>   outcomes: 10 of 10 available
#>   stop-and-search: 5 of 5 available
#>   street: 10 of 10 available
table(snap$members$force_id, snap$members$file_type)
#>                 
#>                  outcomes stop-and-search street
#>   dyfed-powys           5               0      5
#>   west-yorkshire        5               5      5