Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pack/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { MemoryBlockStore } from '../blockstore/memory'
import { pack } from './index'
import type { PackProperties } from './index'

export async function packToBlob ({ input, blockstore: userBlockstore, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) {
export async function packToBlob ({ input, blockstore: userBlockstore, cidVersion, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) {
const blockstore = userBlockstore ? userBlockstore : new MemoryBlockStore()
const { root, out } = await pack({
input,
blockstore,
cidVersion,
hasher,
maxChunkSize,
maxChildrenPerNode,
Expand Down
5 changes: 4 additions & 1 deletion src/pack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export type { ImportCandidateStream }
import { Blockstore } from '../blockstore'
import { MemoryBlockStore } from '../blockstore/memory'
import { unixfsImporterOptionsDefault } from './constants'
import { CIDVersion } from 'multiformats/cid'

export interface PackProperties {
input: ImportCandidateStream | ImportCandidate,
blockstore?: Blockstore,
cidVersion?: CIDVersion;
maxChunkSize?: number,
maxChildrenPerNode?: number,
wrapWithDirectory?: boolean,
Expand All @@ -26,7 +28,7 @@ export interface PackProperties {
rawLeaves?: boolean
}

export async function pack ({ input, blockstore: userBlockstore, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) {
export async function pack ({ input, blockstore: userBlockstore, cidVersion, hasher, maxChunkSize, maxChildrenPerNode, wrapWithDirectory, rawLeaves }: PackProperties) {
if (!input || (Array.isArray(input) && !input.length)) {
throw new Error('missing input file(s)')
}
Expand All @@ -38,6 +40,7 @@ export async function pack ({ input, blockstore: userBlockstore, hasher, maxChun
getNormaliser(input),
(source: any) => importer(source, blockstore, {
...unixfsImporterOptionsDefault,
cidVersion: cidVersion !== undefined ? cidVersion : unixfsImporterOptionsDefault.cidVersion,
hasher: hasher || unixfsImporterOptionsDefault.hasher,
maxChunkSize: maxChunkSize || unixfsImporterOptionsDefault.maxChunkSize,
maxChildrenPerNode: maxChildrenPerNode || unixfsImporterOptionsDefault.maxChildrenPerNode,
Expand Down