Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@
"ipfs-bitswap": "^0.26.2",
"ipfs-block": "~0.8.1",
"ipfs-block-service": "~0.16.0",
"ipfs-http-client": "^41.0.0",
"ipfs-http-client": "^41.0.1",
"ipfs-http-response": "~0.4.0",
"ipfs-mfs": "^0.15.0",
"ipfs-mfs": "^0.16.0",
"ipfs-multipart": "^0.3.0",
"ipfs-repo": "^0.30.0",
"ipfs-unixfs": "^0.3.0",
"ipfs-unixfs-exporter": "^0.40.0",
"ipfs-unixfs-importer": "^0.43.0",
"ipfs-unixfs-exporter": "^0.41.0",
"ipfs-unixfs-importer": "^0.44.0",
"ipfs-utils": "^0.4.2",
"ipld": "~0.25.0",
"ipld-bitcoin": "~0.3.0",
Expand Down Expand Up @@ -204,7 +204,7 @@
"execa": "^3.0.0",
"form-data": "^3.0.0",
"hat": "0.0.3",
"interface-ipfs-core": "^0.127.0",
"interface-ipfs-core": "^0.128.0",
"ipfs-interop": "^0.2.0",
"ipfsd-ctl": "^1.0.2",
"libp2p-websocket-star": "~0.10.2",
Expand Down
29 changes: 7 additions & 22 deletions src/core/components/files-regular/add-async-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,39 +74,24 @@ function transformFile (ipfs, opts) {
return async function * (source) {
for await (const file of source) {
let cid = file.cid
const hash = cid.toBaseEncodedString()
let path = file.path ? file.path : hash

if (opts.wrapWithDirectory && !file.path) {
path = ''
}

if (opts.onlyHash) {
yield {
path,
hash,
size: file.unixfs.fileSize()
}

return
}

const node = await ipfs.object.get(file.cid, Object.assign({}, opts, { preload: false }))

if (opts.cidVersion === 1) {
cid = cid.toV1()
}

let size = node.size
const hash = cid.toBaseEncodedString()
let path = file.path ? file.path : hash

if (Buffer.isBuffer(node)) {
size = node.length
if (opts.wrapWithDirectory && !file.path) {
path = ''
}

yield {
path,
hash,
size
size: file.size,
mode: file.unixfs && file.unixfs.mode,
mtime: file.unixfs && file.unixfs.mtime
}
}
}
Expand Down
18 changes: 13 additions & 5 deletions src/http/api/resources/files-regular.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ exports.add = {
filesParsed = true

yield {
path: entry.name
path: entry.name,
mode: entry.mode,
mtime: entry.mtime
}
}
}
Expand All @@ -233,13 +235,19 @@ exports.add = {
},
async function (source) {
for await (const file of source) {
output.write(JSON.stringify({
const entry = {
Name: file.path,
Hash: cidToString(file.hash, { base: request.query['cid-base'] }),
Size: file.size,
Mode: file.mode === undefined ? undefined : file.mode.toString(8).padStart(4, '0'),
Mtime: file.mtime
}) + '\n')
Mode: file.mode === undefined ? undefined : file.mode.toString(8).padStart(4, '0')
}

if (file.mtime) {
entry.Mtime = file.mtime.secs
entry.MtimeNsecs = file.mtime.nsecs
}

output.write(JSON.stringify(entry) + '\n')
}
}
)
Expand Down