Skip to content

computeLayerHash

computeLayerHash(fs): Promise<string>

Defined in: packages/core/src/kernel/layer.ts:379

Compute the canonical SHA-256 content hash for a frozen memoryFS.

FrozenMemoryFS

Frozen memoryFS to hash.

Promise<string>

Hex SHA-256 of the canonical line format.

Walks the FS in sorted, recursive order and emits one line per entry:

  • file: file|<path>|<size>|<mode>|<content-sha256>
  • dir: dir|<path>|<mode>
  • symlink: symlink|<path>|<target>
  • whiteout: whiteout|<originalPath> (so deletions affect identity)

Instance-specific fields (ino, dev) are excluded — two memoryFS instances with the same content produce the same hash. This is the content-hash input to chainAwareId, not the layer id itself.

import { computeLayerHash } from '@fishnet/core'
const contentHash = await computeLayerHash(frozenFs)