Phase 3.5b: persist image assets in the .beam container

Image asset bytes are now stored as MediaKind::ImageAsset rows in the SQLite
container (chunked, kept-in-place on re-save) instead of base64-embedded in the
project JSON — the pageable storage Phase 4 needs.

- ImageAsset.data is `#[serde(default, skip_serializing)]`: never written to JSON,
  but still deserialized for old projects (base64) which then migrate to the
  container on the next save.
- save_beam writes each asset's bytes (keyed by asset id; ext from the source path),
  keeping an existing row when bytes aren't resident; live_media covers them so orphan
  cleanup doesn't drop them.
- load_beam_sqlite eager-reads the bytes back into `data` (Phase 4 makes this lazy +
  LRU). Old base64 projects keep their JSON-deserialized data (no container row).
This commit is contained in:
Skyler Lehmkuhl
2026-06-21 00:44:18 -04:00
parent aad2d5c515
commit 2f3b0d7790
2 changed files with 44 additions and 3 deletions
@@ -263,9 +263,11 @@ pub struct ImageAsset {
/// Image height in pixels
pub height: u32,
/// Embedded image data (for project portability)
/// If None, the image will be loaded from path when needed
#[serde(skip_serializing_if = "Option::is_none")]
/// Raw image file bytes. NOT serialized to project JSON — persisted as a
/// `MediaKind::ImageAsset` row in the `.beam` container (chunked, pageable) and
/// read back on load. `default` so new projects (bytes in the container, not JSON)
/// deserialize; old projects with base64-embedded `data` still load via deserialize.
#[serde(default, skip_serializing)]
pub data: Option<Vec<u8>>,
/// Folder this asset belongs to (None = root of category)