feat(datamap): write msgpack via ant_core::data::write_datamap#97
Open
Nic-dorman wants to merge 1 commit into
Open
feat(datamap): write msgpack via ant_core::data::write_datamap#97Nic-dorman wants to merge 1 commit into
Nic-dorman wants to merge 1 commit into
Conversation
The read side already delegates to ant_core::data::read_datamap (sniffs the first byte, msgpack canonical / JSON legacy). The write side was still on the local JSON path, which left ant-gui-produced datamaps unreadable by ant-cli's msgpack-only deserializer — closing this gap makes the on-disk format round-trip across tools. Three changes: 1. config::write_datamap_for now takes &DataMap (not the JSON string) and delegates to ant_core::data::write_datamap. msgpack on disk, <name>.<ext>.datamap naming (extension preserved), and upstream's CollisionPolicy::NumericSuffix replaces the local collision loop. 2. Drop sanitize_stem, MAX_COLLISION_ATTEMPTS, DATAMAP_EXTENSION, and std::io::Write / std::path::Path imports. Upstream handles sanitization + atomic tempfile-and-rename + parent-dir fsync on Unix. 3. The three call sites in autonomi_ops.rs pass &result.data_map directly. The data_map_json and SHA-derived address derivations are unchanged — only the on-disk encoding moves. Existing upload_history.json entries keep working: their data_map_file paths still point at JSON datamaps on disk, and read_datamap accepts both formats. New uploads write msgpack with the new naming. No migration needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the ant-gui → ant-cli round-trip gap. The read side already delegates to `ant_core::data::read_datamap` (sniffs first byte: msgpack canonical, JSON legacy), but the write side was still on the local JSON path — so a datamap produced by ant-gui couldn't be opened by `ant file download --datamap` (msgpack-only).
After this PR, ant-gui uploads produce `..datamap` (e.g. `holiday.jpg.datamap`), msgpack-encoded, and read back cleanly in any consumer of `ant_core::data`.
Changes
Net diff: -47 lines.
Compatibility
Existing `upload_history.json` entries reference JSON datamaps on disk via their `data_map_file` path. Those keep working — `read_datamap_file` already accepts both formats. New uploads write msgpack with the extension-preserved naming. Coexistence is intentional; no migration is needed.
Test plan
🤖 Generated with Claude Code