mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-10 20:29:33 -06:00
fix(collab): image checks keep documents shareable and history replayable (#1086)
- The entry size cap is figcraft_doc::ImageData::MAX_BYTES (256 MiB), the cap the .fig, .sketch and REST importers already read images with (now one constant), instead of 32 MiB: an imported image larger than 32 MiB made the document unjoinable and its server snapshot unrestorable. - History written before the checks (a restored or joined snapshot, a replayed server log, a file published to a server) applies without the image entries they refuse (docprops::without_refused_images), instead of the file not opening or a restart dropping every edit after the image. - A key that already holds an image can't be given other bytes: producers key images by their bytes (the REST importer's placeholder keys always hold the same picture), and merge treats a key's image as never changing. - REST import: an unresolved imageRef shaped like a content hash shares the rest-image-missing placeholder (the placeholder's bytes don't hash to it); ImageData::claims_content_hash is shared with collab. - Tests: collab image_tests (4 new, size test uses a small cap), format image_tests (1 new). - Docs: collab-protocol.md, collaboration-parity.md, file-format-parity.md.
This commit is contained in:
@@ -351,7 +351,7 @@ fn link_instances(doc: &mut Document) {
|
||||
|
||||
/// Largest image file read for a REST API file JSON import.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
const MAX_IMAGE_FILE: u64 = 256 * 1024 * 1024;
|
||||
const MAX_IMAGE_FILE: u64 = figcraft_doc::ImageData::MAX_BYTES;
|
||||
|
||||
/// Image bytes for a REST API file JSON's `imageRef`: `images/<imageRef>[.png|.jpg|…]` next to
|
||||
/// the file.
|
||||
|
||||
Reference in New Issue
Block a user