This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
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.
fix: make sure hashes are the same after shard changes
Ensures hashes of sharded directories are the same after adding/removing nodes as if they'd been imported by the importer in their final state. License: MIT Signed-off-by: achingbrain <[email protected]>
- Loading branch information
1 parent
71fd8fa
commit b2fbd5d
Showing
6 changed files
with
363 additions
and
149 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
const load = async (cid, mfs) => { | ||
return new Promise((resolve, reject) => { | ||
mfs.ipld.get(cid, (err, res) => { | ||
if (err) { | ||
return reject(err) | ||
} | ||
|
||
resolve(res.value) | ||
}) | ||
}) | ||
} | ||
|
||
const printTree = async (cid, mfs, indentation = '', name = '') => { | ||
console.info(indentation, name, cid.toBaseEncodedString()) // eslint-disable-line no-console | ||
|
||
const node = await load(cid, mfs) | ||
|
||
for (let i = 0; i < node.links.length; i++) { | ||
await printTree(node.links[i].cid, mfs, ` ${indentation}`, node.links[i].name) | ||
} | ||
} | ||
|
||
module.exports = printTree |
Oops, something went wrong.