Skip to main content

hash_folder_root

Function hash_folder_root 

Source
pub fn hash_folder_root(
    entries: &[FolderEntry],
    opts: &UploadFolderOptions,
) -> Result<Cid, FolderHashError>
Expand description

Build the local UnixFS root CID for entries, matching what kubo’s HTTP /api/v0/add?wrap-with-directory=true produces given the same flat list of files via multipart.

This is a thin wrapper over build_folder_dag that discards block bytes.

This function hashes only the byte content of entries — there is no notion of a UnixFS Symlink node. With follow_symlinks=true (the collect_folder_files default), symlinks are dereferenced by the walker and their target’s bytes are uploaded as regular files. The resulting CID matches ipfs add -r --no-symlinks on the same source, NOT plain ipfs add -r (which would create UnixFS Symlink nodes for each symlink and produce a different CID).

This is a deliberate tradeoff that mirrors the multipart upload path; if symlink-preservation semantics are needed, both the walker and the upload would have to switch to application/x-symlink parts together.