This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
feat!: rename, update, test, type, and ready for launch #2
Open
olizilla
wants to merge
4
commits into
main
Choose a base branch
from
rename-update-add-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Test | ||
description: 'Setup and test' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-node@v3 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
node-version: 18 | ||
cache: 'npm' | ||
- run: npm ci | ||
shell: bash | ||
- run: npm test | ||
shell: bash |
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,20 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
name: Release | ||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: '@web3-storage/ipfs-path' | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/test | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
if: ${{ steps.release.outputs.release_created }} |
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,13 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/test |
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,2 +1,4 @@ | ||
node_modules | ||
fixture | ||
fixture | ||
dist | ||
*.car |
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 |
---|---|---|
|
@@ -35,24 +35,20 @@ export function extract (blockstore, path) { | |
if (!rootBlock) { | ||
throw new Error(`missing root block: ${rootBlock}`) | ||
} | ||
|
||
yield rootBlock | ||
let block = rootBlock | ||
while (parts.length) { | ||
const part = parts.shift() | ||
const part = parts.shift() ?? '' | ||
switch (block.cid.code) { | ||
case dagPB.code: { | ||
yield block | ||
|
||
const node = dagPB.decode(block.bytes) | ||
const unixfs = UnixFS.unmarshal(node.Data) | ||
const unixfs = node.Data ? UnixFS.unmarshal(node.Data) : undefined | ||
|
||
if (unixfs.type === 'hamt-sharded-directory') { | ||
let lastBlock | ||
if (unixfs && unixfs.type === 'hamt-sharded-directory') { | ||
for await (const shardBlock of findShardedBlock(node, part, blockstore)) { | ||
if (lastBlock) yield lastBlock | ||
lastBlock = shardBlock | ||
yield shardBlock | ||
block = shardBlock | ||
} | ||
block = lastBlock | ||
} else { | ||
const link = node.Links.find(link => link.Name === part) | ||
if (!link) { | ||
|
@@ -62,6 +58,7 @@ export function extract (blockstore, path) { | |
if (!linkBlock) { | ||
throw new Error(`missing block: ${linkBlock}`) | ||
} | ||
yield linkBlock | ||
block = linkBlock | ||
} | ||
break | ||
|
@@ -80,7 +77,6 @@ export function extract (blockstore, path) { | |
* @returns {AsyncIterable<Block>} | ||
*/ | ||
async function * exportBlocks (blockstore, block) { | ||
yield block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to yield the block before the recursive call to |
||
switch (block.cid.code) { | ||
case dagPB.code: { | ||
const node = dagPB.decode(block.bytes) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is like it is because
exportBlocks
yields the block you pass to it, so you want to yield all the intermediate blocks here, but not the last one, otherwise you'll yield it twice.Alternatively you could switch it round so that
exportBlocks
does not yield the root block you pass it, but is maybe a bigger change.