MCPcopy Create free account
hub / github.com/chatmail/core / from_path

Method from_path

src/blob.rs:150–159  ·  view source on GitHub ↗

Returns a [BlobObject] for an existing blob from a path. The path must designate a file directly in the blobdir and must use a valid blob name. That is after sanitisation the name must still be the same, that means it must be valid UTF-8 and not have any special characters in it.

(context: &'a Context, path: &Path)

Source from the content-addressed store, hash-verified

148 /// name must still be the same, that means it must be valid UTF-8
149 /// and not have any special characters in it.
150 pub fn from_path(context: &'a Context, path: &Path) -> Result<BlobObject<'a>> {
151 let rel_path = path
152 .strip_prefix(context.get_blobdir())
153 .with_context(|| format!("wrong blobdir: {}", path.display()))?;
154 let name = rel_path.to_str().context("wrong name")?;
155 if !BlobObject::is_acceptible_blob_name(name) {
156 return Err(format_err!("bad blob name: {}", rel_path.display()));
157 }
158 BlobObject::from_name(context, name)
159 }
160
161 /// Returns a [BlobObject] for an existing blob.
162 ///

Callers

nothing calls this directly

Calls 1

get_blobdirMethod · 0.45

Tested by

no test coverage detected