Skip to content

Commit 7e976fb

Browse files
committed
fix: 0005/08 lesson update
1 parent 3d2df04 commit 7e976fb

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/tutorials/0005-regular-files-api/08.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import all from 'it-all'
2+
3+
import utils from '../utils'
4+
15
const validate = async (result, ipfs) => {
2-
const expectedResult = await ipfs.get('QmcmnUvVV31txDfAddgAaNcNKbrtC2rC9FvkJphNWyM7gy')
6+
const expectedResult = await all(ipfs.get('QmcmnUvVV31txDfAddgAaNcNKbrtC2rC9FvkJphNWyM7gy'))
37

48
if (!result) {
59
return {
@@ -26,7 +30,7 @@ const validate = async (result, ipfs) => {
2630
}
2731

2832
let isStructureValid = result.every((elem) => {
29-
if (elem.hash === undefined || typeof elem.hash !== 'string') return false
33+
if (elem.cid === undefined || typeof elem.cid !== 'object') return false
3034
if (elem.path === undefined || typeof elem.path !== 'string') return false
3135
if (elem.name === undefined || typeof elem.name !== 'string') return false
3236
if (elem.depth === undefined || typeof elem.depth !== 'number') return false
@@ -56,33 +60,37 @@ const validate = async (result, ipfs) => {
5660
return {
5761
success: "Congratulations! You've completed this series of lessons!",
5862
logDesc: 'Below is the result of calling the `get` method on the top-level directory. (Normally the results would be much more dense because of the buffered file contents included, but we intentionally created tiny text files to limit this effect.)' +
59-
"\n\n Notice that because we created these files using `{ wrapWithDirectory: true }`, each item's `path` is defined here by the top-level directory's CID plus the item's relative path, and each file or subdirectory has a human-readable `name`. Only the top-level directory itself has a `path` value that matches its `hash` and `name`, all of which are identical CIDs.",
60-
log: result
63+
"\n\n Notice that because we created these files using `{ wrapWithDirectory: true }`, each item's `path` is defined here by the top-level directory's CID plus the item's relative path, and each file or subdirectory has a human-readable `name`. Only the top-level directory itself has a `path` value that matches its `cid` and `name`, all of which are identical CIDs.",
64+
log: result.map(utils.format.ipfsObject)
6165
}
6266
} else {
6367
return { fail: `Something seems to be wrong. Please click "Reset Code" and try again, taking another look at the instructions and editing only the portion of code indicated. Feeling really stuck? You can click "View Solution" to see our suggested code.` }
6468
}
6569
}
6670

6771
const code = `/* global ipfs */
72+
const all = require('it-all')
73+
6874
const run = async () => {
69-
let result = // your code here
75+
let result = await all() // your code here
7076
7177
return result
7278
}
7379
return run
7480
`
7581

7682
const solution = `/* global ipfs */
83+
const all = require('it-all')
84+
7785
const run = async () => {
78-
let result = await ipfs.get('QmcmnUvVV31txDfAddgAaNcNKbrtC2rC9FvkJphNWyM7gy')
86+
let result = await all(ipfs.get('QmcmnUvVV31txDfAddgAaNcNKbrtC2rC9FvkJphNWyM7gy'))
7987
8088
return result
8189
}
8290
return run
8391
`
8492

85-
const modules = { cids: require('cids') }
93+
const modules = { 'it-all': require('it-all') }
8694

8795
const options = {
8896
overrideErrors: true,

src/tutorials/0005-regular-files-api/08.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
type: "code"
44
---
55

6-
Need to know more about an IPFS file or directory beyond just its contents? Whereas `cat` retrieves just the buffered content of a file, we can access addtional metadata about a file or directory by calling the `get` method like so:
6+
Need to know more about an IPFS file or directory beyond just its contents? Whereas `cat` retrieves just the buffered content of a file, we can access additional metadata about a file or directory by calling the `get` method like so:
77

88
```javascript
9-
await ipfs.get(ipfsPath)
9+
ipfs.get(ipfsPath)
1010
```
1111

1212
The result is an array of objects, one per file or directory, with the following structure:

0 commit comments

Comments
 (0)