Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 0161483

Browse files
committed
chore: send directory metadata correctly
1 parent 0768dac commit 0161483

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/interface-ipfs-core/src/add-all.js

+16
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,22 @@ module.exports = (common, options) => {
422422
expect(files[0].size).to.equal(18)
423423
})
424424

425+
it('should add directories with metadata', async () => {
426+
const files = await all(ipfs.addAll([{
427+
path: '/foo',
428+
mode: 0o123,
429+
mtime: {
430+
secs: 1000,
431+
nsecs: 0
432+
}
433+
}]))
434+
435+
expect(files.length).to.equal(1)
436+
expect(files[0].cid.toString()).to.equal('QmaZTosBmPwo9LQ48ESPCEcNuX2kFxkpXYy8i3rxqBdzRG')
437+
expect(files[0].cid.codec).to.equal('dag-pb')
438+
expect(files[0].size).to.equal(11)
439+
})
440+
425441
it('should support bidirectional streaming', async function () {
426442
let progressInvoked
427443

packages/ipfs-grpc-client/src/core-api/add-all.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ function sendDirectory (index, source, path, mode, mtime) {
1313
}
1414

1515
if (mtime) {
16-
message.mtime = mtime
16+
message.mtime = mtime.secs
17+
message.mtimeNsecs = mtime.nsecs
1718
}
1819

1920
if (mode != null) {

0 commit comments

Comments
 (0)