MCPcopy Create free account
hub / github.com/JordanCoin/codemap / WriteLatest

Function WriteLatest

handoff/storage.go:76–94  ·  view source on GitHub ↗

WriteLatest writes an artifact atomically to .codemap/handoff.latest.json.

(root string, artifact *Artifact)

Source from the content-addressed store, hash-verified

74
75// WriteLatest writes an artifact atomically to .codemap/handoff.latest.json.
76func WriteLatest(root string, artifact *Artifact) error {
77 normalizeArtifact(artifact)
78
79 path := LatestPath(root)
80 if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
81 return err
82 }
83
84 if err := writeJSONAtomic(path, artifact); err != nil {
85 return err
86 }
87 if err := writeJSONAtomic(PrefixPath(root), artifact.Prefix); err != nil {
88 return err
89 }
90 if err := writeJSONAtomic(DeltaPath(root), artifact.Delta); err != nil {
91 return err
92 }
93 return appendMetrics(root, artifact)
94}
95
96func writeJSONAtomic(path string, value any) error {
97 data, err := json.MarshalIndent(value, "", " ")

Calls 6

normalizeArtifactFunction · 0.85
LatestPathFunction · 0.85
writeJSONAtomicFunction · 0.85
PrefixPathFunction · 0.85
DeltaPathFunction · 0.85
appendMetricsFunction · 0.85