Skip to content

Commit f6edeca

Browse files
committed
fix: update unixfs importer
1 parent d893bc2 commit f6edeca

11 files changed

+23
-27
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"interface-blockstore": "^4.0.1",
149149
"ipfs-unixfs": "^11.0.0",
150150
"ipfs-unixfs-exporter": "^12.0.0",
151-
"ipfs-unixfs-importer": "^14.0.0",
151+
"ipfs-unixfs-importer": "^14.0.1",
152152
"it-last": "^2.0.0",
153153
"it-pipe": "^2.0.5",
154154
"merge-options": "^3.0.4",

src/commands/chmod.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ export async function chmod (cid: CID, mode: number, blockstore: Blockstore, opt
6363
}
6464
}
6565
},
66-
// @ts-expect-error we account for the incompatible source type with our custom dag builder below
6766
(source) => importer(source, blockstore, {
6867
...opts,
69-
pin: false,
7068
dagBuilder: async function * (source, block) {
7169
for await (const entry of source) {
7270
yield async function () {
@@ -87,7 +85,7 @@ export async function chmod (cid: CID, mode: number, blockstore: Blockstore, opt
8785

8886
return {
8987
cid: updatedCid,
90-
size: buf.length,
88+
size: BigInt(buf.length),
9189
path: entry.path,
9290
unixfs
9391
}

src/commands/touch.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ export async function touch (cid: CID, blockstore: Blockstore, options: Partial<
6767
}
6868
}
6969
},
70-
// @ts-expect-error we account for the incompatible source type with our custom dag builder below
7170
(source) => importer(source, blockstore, {
7271
...opts,
73-
pin: false,
7472
dagBuilder: async function * (source, block) {
7573
for await (const entry of source) {
7674
yield async function () {
@@ -91,7 +89,7 @@ export async function touch (cid: CID, blockstore: Blockstore, options: Partial<
9189

9290
return {
9391
cid: updatedCid,
94-
size: buf.length,
92+
size: BigInt(buf.length),
9593
path: entry.path,
9694
unixfs
9795
}

test/cat.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { unixfs, UnixFS } from '../src/index.js'
77
import { MemoryBlockstore } from 'blockstore-core'
88
import toBuffer from 'it-to-buffer'
99
import drain from 'it-drain'
10-
import { importContent, importBytes } from 'ipfs-unixfs-importer'
10+
import { importDirectory, importBytes } from 'ipfs-unixfs-importer'
1111
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1212

1313
const smallFile = Uint8Array.from(new Array(13).fill(0).map(() => Math.random() * 100))
@@ -22,7 +22,7 @@ describe('cat', () => {
2222

2323
fs = unixfs({ blockstore })
2424

25-
const imported = await importContent({ path: 'empty' }, blockstore)
25+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2626
emptyDirCid = imported.cid
2727
})
2828

test/chmod.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Blockstore } from 'interface-blockstore'
55
import { MemoryBlockstore } from 'blockstore-core'
66
import { UnixFS, unixfs } from '../src/index.js'
77
import type { CID } from 'multiformats/cid'
8-
import { importContent, importBytes } from 'ipfs-unixfs-importer'
8+
import { importDirectory, importBytes } from 'ipfs-unixfs-importer'
99
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1010

1111
const smallFile = Uint8Array.from(new Array(13).fill(0).map(() => Math.random() * 100))
@@ -20,7 +20,7 @@ describe('chmod', () => {
2020

2121
fs = unixfs({ blockstore })
2222

23-
const imported = await importContent({ path: 'empty' }, blockstore)
23+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2424
emptyDirCid = imported.cid
2525
})
2626

test/cp.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Blockstore } from 'interface-blockstore'
88
import { unixfs, UnixFS } from '../src/index.js'
99
import { MemoryBlockstore } from 'blockstore-core'
1010
import toBuffer from 'it-to-buffer'
11-
import { importContent, importBytes } from 'ipfs-unixfs-importer'
11+
import { importDirectory, importBytes } from 'ipfs-unixfs-importer'
1212
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1313
import first from 'it-first'
1414

@@ -22,7 +22,7 @@ describe('cp', () => {
2222

2323
fs = unixfs({ blockstore })
2424

25-
const imported = await importContent({ path: 'empty' }, blockstore)
25+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2626
emptyDirCid = imported.cid
2727
})
2828

test/ls.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import all from 'it-all'
66
import type { Blockstore } from 'interface-blockstore'
77
import { unixfs, UnixFS } from '../src/index.js'
88
import { MemoryBlockstore } from 'blockstore-core'
9-
import { importContent, importBytes } from 'ipfs-unixfs-importer'
9+
import { importDirectory, importBytes } from 'ipfs-unixfs-importer'
1010
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1111

1212
describe('ls', () => {
@@ -19,7 +19,7 @@ describe('ls', () => {
1919

2020
fs = unixfs({ blockstore })
2121

22-
const imported = await importContent({ path: 'empty' }, blockstore)
22+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2323
emptyDirCid = imported.cid
2424
})
2525

test/mkdir.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { unixfs, UnixFS } from '../src/index.js'
77
import { MemoryBlockstore } from 'blockstore-core'
88
import type { CID } from 'multiformats/cid'
99
import type { Mtime } from 'ipfs-unixfs'
10-
import { importContent } from 'ipfs-unixfs-importer'
10+
import { importDirectory } from 'ipfs-unixfs-importer'
1111
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1212

1313
describe('mkdir', () => {
@@ -21,10 +21,10 @@ describe('mkdir', () => {
2121

2222
fs = unixfs({ blockstore })
2323

24-
const imported = await importContent({ path: 'empty' }, blockstore)
24+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2525
emptyDirCid = imported.cid
2626

27-
const importedV0 = await importContent({ path: 'empty' }, blockstore, {
27+
const importedV0 = await importDirectory({ path: 'empty' }, blockstore, {
2828
cidVersion: 0
2929
})
3030
emptyDirCidV0 = importedV0.cid

test/rm.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Blockstore } from 'interface-blockstore'
55
import { unixfs, UnixFS } from '../src/index.js'
66
import { MemoryBlockstore } from 'blockstore-core'
77
import type { CID } from 'multiformats/cid'
8-
import { importContent, importBytes, importer } from 'ipfs-unixfs-importer'
8+
import { importDirectory, importBytes, importer } from 'ipfs-unixfs-importer'
99
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1010
import last from 'it-last'
1111
import { createSubshardedDirectory } from './fixtures/create-subsharded-directory.js'
@@ -22,7 +22,7 @@ describe('rm', () => {
2222

2323
fs = unixfs({ blockstore })
2424

25-
const imported = await importContent({ path: 'empty' }, blockstore)
25+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2626
emptyDirCid = imported.cid
2727
})
2828

test/stat.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { unixfs, UnixFS } from '../src/index.js'
66
import { MemoryBlockstore } from 'blockstore-core'
77
import type { CID } from 'multiformats/cid'
88
import * as dagPb from '@ipld/dag-pb'
9-
import { importContent, importBytes } from 'ipfs-unixfs-importer'
9+
import { importDirectory, importBytes, importFile } from 'ipfs-unixfs-importer'
1010
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1111

1212
const smallFile = Uint8Array.from(new Array(13).fill(0).map(() => Math.random() * 100))
@@ -24,7 +24,7 @@ describe('stat', function () {
2424

2525
fs = unixfs({ blockstore })
2626

27-
const imported = await importContent({ path: 'empty' }, blockstore)
27+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2828
emptyDirCid = imported.cid
2929
})
3030

@@ -100,7 +100,7 @@ describe('stat', function () {
100100

101101
it('should stat file with mode', async () => {
102102
const mode = 0o644
103-
const { cid } = await importContent({
103+
const { cid } = await importFile({
104104
content: smallFile,
105105
mode
106106
}, blockstore)
@@ -115,7 +115,7 @@ describe('stat', function () {
115115
secs: 5n,
116116
nsecs: 0
117117
}
118-
const { cid } = await importContent({
118+
const { cid } = await importFile({
119119
content: smallFile,
120120
mtime
121121
}, blockstore)

test/touch.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { unixfs, UnixFS } from '../src/index.js'
66
import { MemoryBlockstore } from 'blockstore-core'
77
import type { CID } from 'multiformats/cid'
88
import delay from 'delay'
9-
import { importContent, importBytes } from 'ipfs-unixfs-importer'
9+
import { importDirectory, importBytes, importFile } from 'ipfs-unixfs-importer'
1010
import { createShardedDirectory } from './fixtures/create-sharded-directory.js'
1111

1212
describe('.files.touch', () => {
@@ -19,7 +19,7 @@ describe('.files.touch', () => {
1919

2020
fs = unixfs({ blockstore })
2121

22-
const imported = await importContent({ path: 'empty' }, blockstore)
22+
const imported = await importDirectory({ path: 'empty' }, blockstore)
2323
emptyDirCid = imported.cid
2424
})
2525

@@ -43,7 +43,7 @@ describe('.files.touch', () => {
4343
const mtime = new Date()
4444
const seconds = BigInt(Math.floor(mtime.getTime() / 1000))
4545

46-
const { cid } = await importContent({
46+
const { cid } = await importFile({
4747
content: Uint8Array.from([0, 1, 2, 3, 4]),
4848
mtime: {
4949
secs: seconds

0 commit comments

Comments
 (0)