feat(registry): add workspace-scoped artifact metadata
This commit is contained in:
@@ -13,7 +13,7 @@ use std::{
|
||||
use rand::random;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::{ArtifactError, ArtifactRef, MAX_ARTIFACT_BYTES, StoredArtifact};
|
||||
use crate::{ArtifactError, ArtifactRef, MAX_ARTIFACT_BYTES, RegisteredArtifact, StoredArtifact};
|
||||
|
||||
const SHA_DIR: &[u8] = b"sha256";
|
||||
const TEMP_PREFIX: &str = ".crank-artifact-tmp-v1-";
|
||||
@@ -106,6 +106,16 @@ impl ArtifactStore {
|
||||
self.put_reader(&mut io::Cursor::new(bytes))
|
||||
}
|
||||
|
||||
/// Stores bytes and returns a non-forgeable capability suitable for
|
||||
/// creating authoritative registry metadata.
|
||||
pub fn put_registered(&self, bytes: &[u8]) -> Result<RegisteredArtifact, ArtifactError> {
|
||||
let stored = self.put(bytes)?;
|
||||
Ok(RegisteredArtifact {
|
||||
artifact_ref: stored.artifact_ref,
|
||||
size_bytes: stored.size_bytes,
|
||||
})
|
||||
}
|
||||
|
||||
/// Historical spelling retained for source compatibility; bytes are not
|
||||
/// restricted to UTF-8 at this filesystem boundary.
|
||||
pub fn put_utf8(&self, bytes: &[u8]) -> Result<StoredArtifact, ArtifactError> {
|
||||
|
||||
Reference in New Issue
Block a user