@helia/unixfs 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/src/commands/add.d.ts +2 -2
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +1 -1
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/cat.d.ts +1 -1
- package/dist/src/commands/cat.d.ts.map +1 -1
- package/dist/src/commands/cat.js +1 -1
- package/dist/src/commands/cat.js.map +1 -1
- package/dist/src/commands/chmod.d.ts.map +1 -1
- package/dist/src/commands/chmod.js +12 -12
- package/dist/src/commands/chmod.js.map +1 -1
- package/dist/src/commands/cp.d.ts +1 -1
- package/dist/src/commands/cp.d.ts.map +1 -1
- package/dist/src/commands/cp.js +2 -2
- package/dist/src/commands/cp.js.map +1 -1
- package/dist/src/commands/ls.d.ts +2 -2
- package/dist/src/commands/ls.d.ts.map +1 -1
- package/dist/src/commands/ls.js +1 -1
- package/dist/src/commands/ls.js.map +1 -1
- package/dist/src/commands/mkdir.d.ts.map +1 -1
- package/dist/src/commands/mkdir.js +5 -5
- package/dist/src/commands/mkdir.js.map +1 -1
- package/dist/src/commands/rm.d.ts +1 -1
- package/dist/src/commands/rm.d.ts.map +1 -1
- package/dist/src/commands/rm.js +2 -2
- package/dist/src/commands/rm.js.map +1 -1
- package/dist/src/commands/stat.d.ts +1 -1
- package/dist/src/commands/stat.d.ts.map +1 -1
- package/dist/src/commands/stat.js +4 -4
- package/dist/src/commands/stat.js.map +1 -1
- package/dist/src/commands/touch.d.ts.map +1 -1
- package/dist/src/commands/touch.js +12 -12
- package/dist/src/commands/touch.js.map +1 -1
- package/dist/src/commands/utils/add-link.d.ts +3 -3
- package/dist/src/commands/utils/add-link.d.ts.map +1 -1
- package/dist/src/commands/utils/add-link.js +8 -8
- package/dist/src/commands/utils/add-link.js.map +1 -1
- package/dist/src/commands/utils/cid-to-directory.d.ts +3 -3
- package/dist/src/commands/utils/cid-to-directory.d.ts.map +1 -1
- package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
- package/dist/src/commands/utils/cid-to-pblink.d.ts +3 -3
- package/dist/src/commands/utils/cid-to-pblink.d.ts.map +1 -1
- package/dist/src/commands/utils/cid-to-pblink.js +1 -1
- package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
- package/dist/src/commands/utils/consumable-hash.js +9 -0
- package/dist/src/commands/utils/consumable-hash.js.map +1 -1
- package/dist/src/commands/utils/dir-sharded.d.ts +3 -3
- package/dist/src/commands/utils/dir-sharded.d.ts.map +1 -1
- package/dist/src/commands/utils/dir-sharded.js +19 -4
- package/dist/src/commands/utils/dir-sharded.js.map +1 -1
- package/dist/src/commands/utils/errors.js +2 -0
- package/dist/src/commands/utils/errors.js.map +1 -1
- package/dist/src/commands/utils/hamt-utils.d.ts +5 -5
- package/dist/src/commands/utils/hamt-utils.d.ts.map +1 -1
- package/dist/src/commands/utils/hamt-utils.js +5 -5
- package/dist/src/commands/utils/hamt-utils.js.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.js +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
- package/dist/src/commands/utils/persist.d.ts +1 -1
- package/dist/src/commands/utils/persist.d.ts.map +1 -1
- package/dist/src/commands/utils/persist.js +1 -1
- package/dist/src/commands/utils/persist.js.map +1 -1
- package/dist/src/commands/utils/remove-link.d.ts +3 -3
- package/dist/src/commands/utils/remove-link.d.ts.map +1 -1
- package/dist/src/commands/utils/remove-link.js +6 -6
- package/dist/src/commands/utils/remove-link.js.map +1 -1
- package/dist/src/commands/utils/resolve.d.ts +2 -2
- package/dist/src/commands/utils/resolve.d.ts.map +1 -1
- package/dist/src/commands/utils/resolve.js +2 -2
- package/dist/src/commands/utils/resolve.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +14 -13
- package/dist/src/index.js.map +1 -1
- package/package.json +9 -9
- package/src/commands/add.ts +4 -4
- package/src/commands/cat.ts +4 -4
- package/src/commands/chmod.ts +15 -15
- package/src/commands/cp.ts +5 -5
- package/src/commands/ls.ts +5 -5
- package/src/commands/mkdir.ts +7 -7
- package/src/commands/rm.ts +5 -5
- package/src/commands/stat.ts +8 -8
- package/src/commands/touch.ts +15 -15
- package/src/commands/utils/add-link.ts +14 -14
- package/src/commands/utils/cid-to-directory.ts +4 -4
- package/src/commands/utils/cid-to-pblink.ts +4 -4
- package/src/commands/utils/dir-sharded.ts +6 -6
- package/src/commands/utils/hamt-utils.ts +9 -9
- package/src/commands/utils/is-over-shard-threshold.ts +3 -3
- package/src/commands/utils/persist.ts +2 -2
- package/src/commands/utils/remove-link.ts +11 -11
- package/src/commands/utils/resolve.ts +4 -4
- package/src/index.ts +18 -18
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBA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UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,KAA6B;IACnD,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/unixfs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "A Helia-compatible wrapper for UnixFS",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia-unixfs/tree/master/packages/unixfs#readme",
|
|
@@ -149,21 +149,21 @@
|
|
|
149
149
|
"ipfs-unixfs": "^11.0.0",
|
|
150
150
|
"ipfs-unixfs-exporter": "^13.1.0",
|
|
151
151
|
"ipfs-unixfs-importer": "^15.1.0",
|
|
152
|
-
"it-last": "^
|
|
153
|
-
"it-pipe": "^
|
|
152
|
+
"it-last": "^3.0.1",
|
|
153
|
+
"it-pipe": "^3.0.1",
|
|
154
154
|
"merge-options": "^3.0.4",
|
|
155
155
|
"multiformats": "^11.0.1",
|
|
156
156
|
"progress-events": "^1.0.0",
|
|
157
157
|
"sparse-array": "^1.3.2"
|
|
158
158
|
},
|
|
159
159
|
"devDependencies": {
|
|
160
|
-
"aegir": "^
|
|
160
|
+
"aegir": "^39.0.8",
|
|
161
161
|
"blockstore-core": "^4.0.1",
|
|
162
|
-
"delay": "^
|
|
163
|
-
"it-all": "^
|
|
164
|
-
"it-drain": "^
|
|
165
|
-
"it-first": "^
|
|
166
|
-
"it-to-buffer": "^
|
|
162
|
+
"delay": "^6.0.0",
|
|
163
|
+
"it-all": "^3.0.1",
|
|
164
|
+
"it-drain": "^3.0.1",
|
|
165
|
+
"it-first": "^3.0.1",
|
|
166
|
+
"it-to-buffer": "^4.0.1",
|
|
167
167
|
"uint8arrays": "^4.0.3"
|
|
168
168
|
},
|
|
169
169
|
"typedoc": {
|
package/src/commands/add.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
3
|
-
import { ByteStream, DirectoryCandidate, FileCandidate, importBytes, importByteStream, ImportCandidateStream, importDirectory, importer, ImporterOptions, importFile, ImportResult } from 'ipfs-unixfs-importer'
|
|
4
|
-
import { balanced } from 'ipfs-unixfs-importer/layout'
|
|
1
|
+
import { type ByteStream, type DirectoryCandidate, type FileCandidate, importBytes, importByteStream, type ImportCandidateStream, importDirectory, importer, type ImporterOptions, importFile, type ImportResult } from 'ipfs-unixfs-importer'
|
|
5
2
|
import { fixedSize } from 'ipfs-unixfs-importer/chunker'
|
|
3
|
+
import { balanced } from 'ipfs-unixfs-importer/layout'
|
|
4
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
5
|
+
import type { CID } from 'multiformats/cid'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Default importer settings match Filecoin
|
package/src/commands/cat.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { exporter } from 'ipfs-unixfs-exporter'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import type { CatOptions } from '../index.js'
|
|
4
|
-
import { resolve } from './utils/resolve.js'
|
|
5
2
|
import mergeOpts from 'merge-options'
|
|
6
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
7
3
|
import { NoContentError, NotAFileError } from './utils/errors.js'
|
|
4
|
+
import { resolve } from './utils/resolve.js'
|
|
5
|
+
import type { CatOptions } from '../index.js'
|
|
6
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
7
|
+
import type { CID } from 'multiformats/cid'
|
|
8
8
|
|
|
9
9
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
10
10
|
|
package/src/commands/chmod.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CID } from 'multiformats/cid'
|
|
3
|
-
import type { ChmodOptions } from '../index.js'
|
|
4
|
-
import mergeOpts from 'merge-options'
|
|
1
|
+
import * as dagPB from '@ipld/dag-pb'
|
|
5
2
|
import { logger } from '@libp2p/logger'
|
|
6
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
7
|
-
import {
|
|
8
|
-
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
|
|
9
|
-
import * as dagPB from '@ipld/dag-pb'
|
|
10
|
-
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
4
|
+
import { recursive } from 'ipfs-unixfs-exporter'
|
|
11
5
|
import { importer } from 'ipfs-unixfs-importer'
|
|
12
|
-
import { persist } from './utils/persist.js'
|
|
13
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
14
6
|
import last from 'it-last'
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
7
|
+
import { pipe } from 'it-pipe'
|
|
8
|
+
import mergeOpts from 'merge-options'
|
|
9
|
+
import { CID } from 'multiformats/cid'
|
|
17
10
|
import * as raw from 'multiformats/codecs/raw'
|
|
11
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
18
12
|
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
|
|
13
|
+
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
|
|
14
|
+
import { persist } from './utils/persist.js'
|
|
15
|
+
import { resolve, updatePathCids } from './utils/resolve.js'
|
|
16
|
+
import type { ChmodOptions } from '../index.js'
|
|
17
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
18
|
+
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
19
19
|
|
|
20
20
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
21
21
|
const log = logger('helia:unixfs:chmod')
|
|
@@ -94,14 +94,14 @@ export async function chmod (cid: CID, mode: number, blockstore: Blocks, options
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}),
|
|
97
|
-
async (nodes) =>
|
|
97
|
+
async (nodes) => last(nodes)
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
if (root == null) {
|
|
101
101
|
throw new UnknownError(`Could not chmod ${resolved.cid.toString()}`)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
return
|
|
104
|
+
return updatePathCids(root.cid, resolved, blockstore, opts)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const block = await blockstore.get(resolved.cid)
|
|
@@ -133,5 +133,5 @@ export async function chmod (cid: CID, mode: number, blockstore: Blocks, options
|
|
|
133
133
|
|
|
134
134
|
await blockstore.put(updatedCid, updatedBlock)
|
|
135
135
|
|
|
136
|
-
return
|
|
136
|
+
return updatePathCids(updatedCid, resolved, blockstore, opts)
|
|
137
137
|
}
|
package/src/commands/cp.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import type { CpOptions } from '../index.js'
|
|
4
|
-
import mergeOpts from 'merge-options'
|
|
5
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
+
import mergeOpts from 'merge-options'
|
|
6
3
|
import { addLink } from './utils/add-link.js'
|
|
7
|
-
import { cidToPBLink } from './utils/cid-to-pblink.js'
|
|
8
4
|
import { cidToDirectory } from './utils/cid-to-directory.js'
|
|
5
|
+
import { cidToPBLink } from './utils/cid-to-pblink.js'
|
|
9
6
|
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
|
|
10
7
|
import { InvalidParametersError } from './utils/errors.js'
|
|
8
|
+
import type { CpOptions } from '../index.js'
|
|
9
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
10
|
+
import type { CID } from 'multiformats/cid'
|
|
11
11
|
|
|
12
12
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
13
13
|
const log = logger('helia:unixfs:cp')
|
package/src/commands/ls.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { exporter, UnixFSEntry } from 'ipfs-unixfs-exporter'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import type { LsOptions } from '../index.js'
|
|
4
|
-
import { resolve } from './utils/resolve.js'
|
|
1
|
+
import { exporter, type UnixFSEntry } from 'ipfs-unixfs-exporter'
|
|
5
2
|
import mergeOpts from 'merge-options'
|
|
6
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
7
3
|
import { NoContentError, NotADirectoryError } from './utils/errors.js'
|
|
4
|
+
import { resolve } from './utils/resolve.js'
|
|
5
|
+
import type { LsOptions } from '../index.js'
|
|
6
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
7
|
+
import type { CID } from 'multiformats/cid'
|
|
8
8
|
|
|
9
9
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
10
10
|
|
package/src/commands/mkdir.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid'
|
|
2
|
-
import mergeOpts from 'merge-options'
|
|
3
|
-
import { logger } from '@libp2p/logger'
|
|
4
|
-
import type { MkdirOptions } from '../index.js'
|
|
5
1
|
import * as dagPB from '@ipld/dag-pb'
|
|
6
|
-
import {
|
|
7
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
2
|
+
import { logger } from '@libp2p/logger'
|
|
8
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
9
|
-
import { sha256 } from 'multiformats/hashes/sha2'
|
|
10
4
|
import { exporter } from 'ipfs-unixfs-exporter'
|
|
5
|
+
import mergeOpts from 'merge-options'
|
|
6
|
+
import { CID } from 'multiformats/cid'
|
|
7
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
8
|
+
import { addLink } from './utils/add-link.js'
|
|
11
9
|
import { cidToDirectory } from './utils/cid-to-directory.js'
|
|
12
10
|
import { cidToPBLink } from './utils/cid-to-pblink.js'
|
|
13
11
|
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
|
|
14
12
|
import { InvalidParametersError, NotADirectoryError } from './utils/errors.js'
|
|
13
|
+
import type { MkdirOptions } from '../index.js'
|
|
14
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
15
15
|
|
|
16
16
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
17
17
|
const log = logger('helia:unixfs:mkdir')
|
package/src/commands/rm.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import type { RmOptions } from '../index.js'
|
|
4
|
-
import mergeOpts from 'merge-options'
|
|
5
1
|
import { logger } from '@libp2p/logger'
|
|
6
|
-
import
|
|
2
|
+
import mergeOpts from 'merge-options'
|
|
7
3
|
import { cidToDirectory } from './utils/cid-to-directory.js'
|
|
8
4
|
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
|
|
9
5
|
import { InvalidParametersError } from './utils/errors.js'
|
|
6
|
+
import { removeLink } from './utils/remove-link.js'
|
|
7
|
+
import type { RmOptions } from '../index.js'
|
|
8
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
9
|
+
import type { CID } from 'multiformats/cid'
|
|
10
10
|
|
|
11
11
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
12
12
|
const log = logger('helia:unixfs:rm')
|
package/src/commands/stat.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import type { StatOptions, UnixFSStats } from '../index.js'
|
|
4
|
-
import mergeOpts from 'merge-options'
|
|
1
|
+
import * as dagPb from '@ipld/dag-pb'
|
|
5
2
|
import { logger } from '@libp2p/logger'
|
|
6
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
4
|
+
import { exporter } from 'ipfs-unixfs-exporter'
|
|
5
|
+
import mergeOpts from 'merge-options'
|
|
6
|
+
import * as raw from 'multiformats/codecs/raw'
|
|
7
7
|
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
|
|
8
|
-
import * as dagPb from '@ipld/dag-pb'
|
|
9
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
10
|
-
import type { Mtime } from 'ipfs-unixfs'
|
|
11
8
|
import { resolve } from './utils/resolve.js'
|
|
12
|
-
import
|
|
9
|
+
import type { StatOptions, UnixFSStats } from '../index.js'
|
|
13
10
|
import type { Blocks } from '@helia/interface/blocks'
|
|
11
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
12
|
+
import type { Mtime } from 'ipfs-unixfs'
|
|
13
|
+
import type { CID } from 'multiformats/cid'
|
|
14
14
|
|
|
15
15
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
16
16
|
const log = logger('helia:unixfs:stat')
|
package/src/commands/touch.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CID } from 'multiformats/cid'
|
|
3
|
-
import type { TouchOptions } from '../index.js'
|
|
4
|
-
import mergeOpts from 'merge-options'
|
|
1
|
+
import * as dagPB from '@ipld/dag-pb'
|
|
5
2
|
import { logger } from '@libp2p/logger'
|
|
6
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
7
|
-
import {
|
|
8
|
-
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
|
|
9
|
-
import * as dagPB from '@ipld/dag-pb'
|
|
10
|
-
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
4
|
+
import { recursive } from 'ipfs-unixfs-exporter'
|
|
11
5
|
import { importer } from 'ipfs-unixfs-importer'
|
|
12
|
-
import { persist } from './utils/persist.js'
|
|
13
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
14
6
|
import last from 'it-last'
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
7
|
+
import { pipe } from 'it-pipe'
|
|
8
|
+
import mergeOpts from 'merge-options'
|
|
9
|
+
import { CID } from 'multiformats/cid'
|
|
17
10
|
import * as raw from 'multiformats/codecs/raw'
|
|
11
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
18
12
|
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
|
|
13
|
+
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
|
|
14
|
+
import { persist } from './utils/persist.js'
|
|
15
|
+
import { resolve, updatePathCids } from './utils/resolve.js'
|
|
16
|
+
import type { TouchOptions } from '../index.js'
|
|
17
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
18
|
+
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
19
19
|
|
|
20
20
|
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
|
|
21
21
|
const log = logger('helia:unixfs:touch')
|
|
@@ -98,14 +98,14 @@ export async function touch (cid: CID, blockstore: Blocks, options: Partial<Touc
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}),
|
|
101
|
-
async (nodes) =>
|
|
101
|
+
async (nodes) => last(nodes)
|
|
102
102
|
)
|
|
103
103
|
|
|
104
104
|
if (root == null) {
|
|
105
105
|
throw new UnknownError(`Could not chmod ${resolved.cid.toString()}`)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
return
|
|
108
|
+
return updatePathCids(root.cid, resolved, blockstore, opts)
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const block = await blockstore.get(resolved.cid)
|
|
@@ -136,5 +136,5 @@ export async function touch (cid: CID, blockstore: Blocks, options: Partial<Touc
|
|
|
136
136
|
|
|
137
137
|
await blockstore.put(updatedCid, updatedBlock)
|
|
138
138
|
|
|
139
|
-
return
|
|
139
|
+
return updatePathCids(updatedCid, resolved, blockstore, opts)
|
|
140
140
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import * as dagPB from '@ipld/dag-pb'
|
|
2
|
-
import { CID, Version } from 'multiformats/cid'
|
|
3
2
|
import { logger } from '@libp2p/logger'
|
|
4
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
4
|
+
import { CID, type Version } from 'multiformats/cid'
|
|
5
|
+
import { sha256 } from 'multiformats/hashes/sha2'
|
|
6
|
+
// @ts-expect-error no types
|
|
7
|
+
import SparseArray from 'sparse-array'
|
|
8
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
9
|
+
import { wrapHash } from './consumable-hash.js'
|
|
10
|
+
import { AlreadyExistsError, InvalidParametersError, InvalidPBNodeError } from './errors.js'
|
|
11
|
+
import { hamtBucketBits, hamtHashFn } from './hamt-constants.js'
|
|
5
12
|
import {
|
|
6
13
|
createShard,
|
|
7
14
|
recreateShardedDirectory,
|
|
8
15
|
toPrefix,
|
|
9
16
|
updateShardedDirectory
|
|
10
17
|
} from './hamt-utils.js'
|
|
11
|
-
import
|
|
12
|
-
import { sha256 } from 'multiformats/hashes/sha2'
|
|
13
|
-
import { AlreadyExistsError, InvalidParametersError, InvalidPBNodeError } from './errors.js'
|
|
14
|
-
import type { ImportResult } from 'ipfs-unixfs-importer'
|
|
15
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
18
|
+
import { isOverShardThreshold } from './is-over-shard-threshold.js'
|
|
16
19
|
import type { Directory } from './cid-to-directory.js'
|
|
17
20
|
import type { Blocks } from '@helia/interface/blocks'
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import SparseArray from 'sparse-array'
|
|
22
|
-
import { wrapHash } from './consumable-hash.js'
|
|
23
|
-
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
21
|
+
import type { PBNode, PBLink } from '@ipld/dag-pb/interface'
|
|
22
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
23
|
+
import type { ImportResult } from 'ipfs-unixfs-importer'
|
|
24
24
|
|
|
25
25
|
const log = logger('helia:unixfs:components:utils:add-link')
|
|
26
26
|
|
|
@@ -45,7 +45,7 @@ export async function addLink (parent: Directory, child: Required<PBLink>, block
|
|
|
45
45
|
if (meta.type === 'hamt-sharded-directory') {
|
|
46
46
|
log('adding link to sharded directory')
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return addToShardedDirectory(parent, child, blockstore, options)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
log(`adding ${child.Name} (${child.Hash}) to regular directory`)
|
|
@@ -253,5 +253,5 @@ const addToShardedDirectory = async (parent: Directory, child: Required<PBLink>,
|
|
|
253
253
|
log('adding %s to existing sub-shard', linkName)
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
return
|
|
256
|
+
return updateShardedDirectory(path, blockstore, options)
|
|
257
257
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { exporter, ExporterOptions } from 'ipfs-unixfs-exporter'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import type { PBNode } from '@ipld/dag-pb'
|
|
4
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
1
|
+
import { exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
|
|
5
2
|
import { NotADirectoryError } from './errors.js'
|
|
3
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
4
|
+
import type { PBNode } from '@ipld/dag-pb'
|
|
5
|
+
import type { CID } from 'multiformats/cid'
|
|
6
6
|
|
|
7
7
|
export interface Directory {
|
|
8
8
|
cid: CID
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { exporter, ExporterOptions } from 'ipfs-unixfs-exporter'
|
|
2
|
-
import type { CID } from 'multiformats/cid'
|
|
3
|
-
import { NotUnixFSError } from './errors.js'
|
|
4
1
|
import * as dagPb from '@ipld/dag-pb'
|
|
5
|
-
import
|
|
2
|
+
import { exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
|
|
3
|
+
import { NotUnixFSError } from './errors.js'
|
|
6
4
|
import type { Blocks } from '@helia/interface/blocks'
|
|
5
|
+
import type { PBNode, PBLink } from '@ipld/dag-pb'
|
|
6
|
+
import type { CID } from 'multiformats/cid'
|
|
7
7
|
|
|
8
8
|
export async function cidToPBLink (cid: CID, name: string, blockstore: Blocks, options?: ExporterOptions): Promise<Required<PBLink>> {
|
|
9
9
|
const sourceEntry = await exporter(cid, blockstore, options)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { encode, PBLink, prepare } from '@ipld/dag-pb'
|
|
1
|
+
import { encode, type PBLink, prepare } from '@ipld/dag-pb'
|
|
2
|
+
import { createHAMT, Bucket, type BucketChild } from 'hamt-sharding'
|
|
2
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
3
|
-
import {
|
|
4
|
-
import { createHAMT, Bucket, BucketChild } from 'hamt-sharding'
|
|
4
|
+
import { CID } from 'multiformats/cid'
|
|
5
5
|
import {
|
|
6
6
|
hamtHashCode,
|
|
7
7
|
hamtHashFn
|
|
8
8
|
} from './hamt-constants.js'
|
|
9
|
-
import {
|
|
10
|
-
import type { Mtime } from 'ipfs-unixfs'
|
|
9
|
+
import { persist, type PersistOptions } from './persist.js'
|
|
11
10
|
import type { Blocks } from '@helia/interface/blocks'
|
|
11
|
+
import type { Mtime } from 'ipfs-unixfs'
|
|
12
12
|
|
|
13
13
|
interface InProgressImportResult extends ImportResult {
|
|
14
14
|
single?: boolean
|
|
@@ -95,7 +95,7 @@ export class DirSharded extends Dir {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
async get (name: string): Promise<InProgressImportResult | Dir | undefined> {
|
|
98
|
-
return
|
|
98
|
+
return this._bucket.get(name)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
childCount (): number {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import * as dagPB from '@ipld/dag-pb'
|
|
2
|
-
import { DirSharded } from './dir-sharded.js'
|
|
3
2
|
import { logger } from '@libp2p/logger'
|
|
4
3
|
import { UnixFS } from 'ipfs-unixfs'
|
|
5
4
|
import last from 'it-last'
|
|
6
|
-
|
|
5
|
+
// @ts-expect-error no types
|
|
6
|
+
import SparseArray from 'sparse-array'
|
|
7
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
8
|
+
import { type InfiniteHash, wrapHash } from './consumable-hash.js'
|
|
9
|
+
import { DirSharded } from './dir-sharded.js'
|
|
7
10
|
import {
|
|
8
11
|
hamtHashCode,
|
|
9
12
|
hamtHashFn,
|
|
10
13
|
hamtBucketBits
|
|
11
14
|
} from './hamt-constants.js'
|
|
15
|
+
import { persist } from './persist.js'
|
|
16
|
+
import type { PersistOptions } from './persist.js'
|
|
12
17
|
import type { Blocks } from '@helia/interface/blocks'
|
|
13
|
-
import type { Mtime } from 'ipfs-unixfs'
|
|
14
18
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
19
|
+
import type { Mtime } from 'ipfs-unixfs'
|
|
15
20
|
import type { ImportResult } from 'ipfs-unixfs-importer'
|
|
16
|
-
import {
|
|
17
|
-
import { InfiniteHash, wrapHash } from './consumable-hash.js'
|
|
18
|
-
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
19
|
-
// @ts-expect-error no types
|
|
20
|
-
import SparseArray from 'sparse-array'
|
|
21
|
-
import type { PersistOptions } from './persist.js'
|
|
21
|
+
import type { CID, Version } from 'multiformats/cid'
|
|
22
22
|
|
|
23
23
|
const log = logger('helia:unixfs:commands:utils:hamt-utils')
|
|
24
24
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { PBNode } from '@ipld/dag-pb'
|
|
2
|
-
import type { Blocks } from '@helia/interface/blocks'
|
|
3
|
-
import { UnixFS } from 'ipfs-unixfs'
|
|
4
1
|
import * as dagPb from '@ipld/dag-pb'
|
|
2
|
+
import { UnixFS } from 'ipfs-unixfs'
|
|
5
3
|
import { CID_V0, CID_V1 } from './dir-sharded.js'
|
|
4
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
5
|
+
import type { PBNode } from '@ipld/dag-pb'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Estimate node size only based on DAGLink name and CID byte lengths
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid'
|
|
2
1
|
import * as dagPb from '@ipld/dag-pb'
|
|
2
|
+
import { CID } from 'multiformats/cid'
|
|
3
3
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
4
4
|
import type { Blocks } from '@helia/interface/blocks'
|
|
5
|
-
import type { BlockCodec } from 'multiformats/codecs/interface'
|
|
6
5
|
import type { Version as CIDVersion } from 'multiformats/cid'
|
|
6
|
+
import type { BlockCodec } from 'multiformats/codecs/interface'
|
|
7
7
|
|
|
8
8
|
export interface PersistOptions {
|
|
9
9
|
codec?: BlockCodec<any, any>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
import * as dagPB from '@ipld/dag-pb'
|
|
3
|
-
import type { CID, Version } from 'multiformats/cid'
|
|
4
3
|
import { logger } from '@libp2p/logger'
|
|
5
4
|
import { UnixFS } from 'ipfs-unixfs'
|
|
5
|
+
import { exporter } from 'ipfs-unixfs-exporter'
|
|
6
|
+
import { InvalidParametersError, InvalidPBNodeError } from './errors.js'
|
|
6
7
|
import {
|
|
7
8
|
recreateShardedDirectory,
|
|
8
|
-
UpdateHamtDirectoryOptions,
|
|
9
|
+
type UpdateHamtDirectoryOptions,
|
|
9
10
|
updateShardedDirectory
|
|
10
11
|
} from './hamt-utils.js'
|
|
11
|
-
import
|
|
12
|
-
import
|
|
12
|
+
import { isOverShardThreshold } from './is-over-shard-threshold.js'
|
|
13
|
+
import { persist } from './persist.js'
|
|
13
14
|
import type { Directory } from './cid-to-directory.js'
|
|
15
|
+
import type { Blocks } from '@helia/interface/blocks'
|
|
16
|
+
import type { PBNode } from '@ipld/dag-pb'
|
|
14
17
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
15
|
-
import {
|
|
16
|
-
import { exporter } from 'ipfs-unixfs-exporter'
|
|
17
|
-
import { persist } from './persist.js'
|
|
18
|
-
import { isOverShardThreshold } from './is-over-shard-threshold.js'
|
|
18
|
+
import type { CID, Version } from 'multiformats/cid'
|
|
19
19
|
|
|
20
20
|
const log = logger('helia:unixfs:utils:remove-link')
|
|
21
21
|
|
|
@@ -44,7 +44,7 @@ export async function removeLink (parent: Directory, name: string, blockstore: B
|
|
|
44
44
|
if (!(await isOverShardThreshold(result.node, blockstore, options.shardSplitThresholdBytes))) {
|
|
45
45
|
log('converting shard to flat directory %c', parent.cid)
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return convertToFlatDirectory(result, blockstore, options)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return result
|
|
@@ -52,7 +52,7 @@ export async function removeLink (parent: Directory, name: string, blockstore: B
|
|
|
52
52
|
|
|
53
53
|
log(`removing link ${name} regular directory`)
|
|
54
54
|
|
|
55
|
-
return
|
|
55
|
+
return removeFromDirectory(parent, name, blockstore, options)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const removeFromDirectory = async (parent: Directory, name: string, blockstore: Blocks, options: AbortOptions): Promise<RemoveLinkResult> => {
|
|
@@ -129,7 +129,7 @@ const removeFromShardedDirectory = async (parent: Directory, name: string, block
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
return
|
|
132
|
+
return updateShardedDirectory(path, blockstore, options)
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
const convertToFlatDirectory = async (parent: Directory, blockstore: Blocks, options: RmLinkOptions): Promise<RemoveLinkResult> => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { CID } from 'multiformats/cid'
|
|
2
|
-
import { exporter } from 'ipfs-unixfs-exporter'
|
|
3
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
4
1
|
import { logger } from '@libp2p/logger'
|
|
5
|
-
import {
|
|
2
|
+
import { exporter } from 'ipfs-unixfs-exporter'
|
|
6
3
|
import { addLink } from './add-link.js'
|
|
7
4
|
import { cidToDirectory } from './cid-to-directory.js'
|
|
8
5
|
import { cidToPBLink } from './cid-to-pblink.js'
|
|
6
|
+
import { DoesNotExistError, InvalidParametersError } from './errors.js'
|
|
9
7
|
import type { Blocks } from '@helia/interface/blocks'
|
|
8
|
+
import type { AbortOptions } from '@libp2p/interfaces'
|
|
9
|
+
import type { CID } from 'multiformats/cid'
|
|
10
10
|
|
|
11
11
|
const log = logger('helia:unixfs:components:utils:resolve')
|
|
12
12
|
|