-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(ipos):
/pinFile
car file to v0
cid
- Loading branch information
Showing
7 changed files
with
35 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,10 @@ | |
"engines": { | ||
"pnpm": ">=9", | ||
"node": ">=20" | ||
}, | ||
"pnpm": { | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/dist/esm/pack/index.js b/dist/esm/pack/index.js | ||
index 97e262734c587f31b89aeaf370d11bb4760f33f0..fe0f34ce16a9a5a79174a0d9f7a33c6d63a9e637 100644 | ||
--- a/dist/esm/pack/index.js | ||
+++ b/dist/esm/pack/index.js | ||
@@ -13,6 +13,7 @@ export async function pack({ input, blockstore: userBlockstore, hasher, maxChunk | ||
// Consume the source | ||
const rootEntry = await last(pipe(getNormaliser(input), (source) => importer(source, blockstore, { | ||
...unixfsImporterOptionsDefault, | ||
+ cidVersion: 0, | ||
hasher: hasher || unixfsImporterOptionsDefault.hasher, | ||
maxChunkSize: maxChunkSize || unixfsImporterOptionsDefault.maxChunkSize, | ||
maxChildrenPerNode: maxChildrenPerNode || unixfsImporterOptionsDefault.maxChildrenPerNode, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
import { MemoryBlockStore } from 'ipfs-car/blockstore/memory' | ||
import { pack } from 'ipfs-car/pack' | ||
// Patch: `ipfs-car` library has been patched to work with CID v0 which is not supported by the original implementation. | ||
// see `import { pack } from 'ipfs-car/pack'` | ||
import { packToBlob } from 'ipfs-car/pack/blob' | ||
import type { CID } from 'multiformats' | ||
|
||
export default async function toCar( | ||
input: { path: string; content: Uint8Array }[], | ||
) { | ||
const { root, out } = await pack({ | ||
const { root, car } = await packToBlob({ | ||
input: input, | ||
blockstore: new MemoryBlockStore(), | ||
wrapWithDirectory: true, | ||
}) | ||
|
||
const chunks = [] | ||
for await (const chunk of out) { | ||
chunks.push(chunk) | ||
} | ||
|
||
const car = new Uint8Array( | ||
chunks.reduce((acc, chunk) => acc.concat(Array.from(chunk)), []), | ||
) | ||
|
||
return { | ||
root: root as CID, | ||
car, | ||
car: car as Blob, | ||
} | ||
} |