Skip to contents

Saves a snapshot dataset (typically produced by scan_storage()) as a uniquely identified .rds file.

Usage

save_scan(df, storage_id, path, label = NULL)

Arguments

df

Data.frame. Scan result with created with scan_storage() that has a created_at attribute.

storage_id

Character. Identifier of the storage.

path

Character. Directory where the file will be saved.

label

Character. Optional human-readable label describing the scanned scope (e.g. "d_eviota"). Default is NULL (no label).

Value

Invisibly returns the full file path of the saved .rds file.

Details

The filename encodes:

  • storage context

  • observation time

  • optional scope label

  • a deterministic hash

This ensures:

  • chronological ordering

  • uniqueness

  • reproducibility of stored observations

Examples

tmp_dir <- tempfile()
dir.create(tmp_dir)

dir.create(file.path(tmp_dir, "R"))
dir.create(file.path(tmp_dir, "data"))

file.create(file.path(tmp_dir, "R", "a.R"))
#> [1] TRUE
file.create(file.path(tmp_dir, "R", "b.R"))
#> [1] TRUE
file.create(file.path(tmp_dir, "data", "c.csv"))
#> [1] TRUE

scan <- scan_storage(
  root = tmp_dir,
  storage_id = "test-storage"
)
#> Starting scan_storage() on: C:/Users/DANIEL~1/AppData/Local/Temp/RtmpAVSpsT/file36f477101a45
#> Scanning 3 files.
#> Signatures computed. Detecting repositories and Git status...
#> Files scanned: 3
#> Files in Git repos: 0
#> Files tracked by Git: 0
#> Skipped approximately 0 inaccessible files
#> scan_storage completed in 0.11 seconds

save_scan(
  df = scan,
  storage_id = "test-storage",
  path = tmp_dir
)
#> Saved: C:\Users\DANIEL~1\AppData\Local\Temp\RtmpAVSpsT\file36f477101a45/scan_test-storage_20260715-110037_e78a18.rds