Function tvix_castore::import::ingest_entries

source ยท
pub async fn ingest_entries<DS, S, E>(
    directory_service: DS,
    entries: S,
) -> Result<Node, IngestionError<E>>
where DS: DirectoryService, S: Stream<Item = Result<IngestionEntry, E>> + Send + Unpin, E: Error,
Expand description

Ingests IngestionEntry from the given stream into a the passed DirectoryService. On success, returns the root Node.

The stream must have the following invariants:

  • All children entries must come before their parents.
  • The last entry must be the root node which must have a single path component.
  • Every entry should have a unique path, and only consist of normal components. This means, no windows path prefixes, absolute paths, . or ...
  • All referenced directories must have an associated directory entry in the stream. This means if there is a file entry for foo/bar, there must also be a foo directory entry.

Internally we maintain a HashMap of PathBuf to partially populated Directory at that path. Once we receive an IngestionEntry for the directory itself, we remove it from the map and upload it to the DirectoryService through a lazily created DirectoryPutter.

On success, returns the root node.