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

Commit 00c9c4e

Browse files
committed
chore: updates types etc from unixfs
1 parent f729536 commit 00c9c4e

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

packages/ipfs-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"ipfs-core-utils": "^0.7.1",
7575
"ipfs-repo": "^8.0.0",
7676
"ipfs-unixfs": "^3.0.0",
77-
"ipfs-unixfs-exporter": "^4.0.0",
77+
"ipfs-unixfs-exporter": "https://gitpkg.now.sh/ipfs/js-ipfs-unixfs/packages/ipfs-unixfs-exporter?fix/use-ipfs-core-types",
7878
"ipfs-unixfs-importer": "^6.0.0",
7979
"ipfs-utils": "^6.0.1",
8080
"ipld": "^0.28.0",

packages/ipfs-core/src/components/files/chmod.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ module.exports = (context) => {
210210
dagBuilder: async function * (source, block, opts) {
211211
for await (const entry of source) {
212212
yield async function () {
213-
const buf = entry.content.serialize()
213+
/** @type {DAGNode} */
214+
// @ts-ignore
215+
const node = entry.content
216+
217+
const buf = node.serialize()
214218
const cid = await persist(buf, block, opts)
215-
const unixfs = UnixFS.unmarshal(entry.content.Data)
219+
const unixfs = UnixFS.unmarshal(node.Data)
216220

217221
return {
218222
cid,
@@ -227,6 +231,10 @@ module.exports = (context) => {
227231
(nodes) => last(nodes)
228232
)
229233

234+
if (!root) {
235+
throw errCode(new Error(`Could not chmod ${path}`), 'ERR_COULD_NOT_CHMOD')
236+
}
237+
230238
// remove old path from mfs
231239
await rm(context)(path, opts)
232240

packages/ipfs-core/src/components/files/utils/add-link.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ const addToDirectory = async (context, options) => {
9999

100100
if (node.mtime) {
101101
// Update mtime if previously set
102-
node.mtime = new Date()
102+
const ms = Date.now()
103+
const secs = Math.floor(ms / 1000)
104+
105+
node.mtime = {
106+
secs: secs,
107+
nsecs: (ms - (secs * 1000)) * 1000
108+
}
103109

104110
options.parent = new DAGNode(node.marshal(), options.parent.Links)
105111
}

packages/ipfs-core/src/components/files/write.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ const write = async (context, source, destination, options) => {
229229
pin: false
230230
}))
231231

232+
if (!result) {
233+
throw errCode(new Error(`cannot write to ${parent.name}`), 'ERR_COULD_NOT_WRITE')
234+
}
235+
232236
log(`Wrote ${result.cid}`)
233237

234238
return {

0 commit comments

Comments
 (0)