You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ Arguments:
142
142
143
143
*`path` (string, mandatory): the path for this repo
144
144
*`options` (object, optional): may contain the following values
145
-
*`lock` (string *Deprecated* or [Lock](#lock)), string can be `"fs"`or `"memory"`: what type of lock to use. Lock has to be acquired when opening.
145
+
*`lock` ([Lock](#lock)or string *Deprecated*): what type of lock to use. Lock has to be acquired when opening. string can be `"fs"` or `"memory"`.
146
146
*`storageBackends` (object, optional): may contain the following values, which should each be a class implementing the [datastore interface](https://github.com/ipfs/interface-datastore#readme):
147
147
*`root` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at the root (`repo.set()`, `repo.get()`)
148
148
*`blocks` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at `repo.blocks`.
@@ -302,12 +302,14 @@ IPFS Repo comes with two built in locks: memory and fs. These can be imported vi
302
302
303
303
```js
304
304
constfsLock=require('ipfs-repo/src/lock') // Default in Node.js
305
-
constmemLock=require('ipfs-repo/src/lock-memory') // Default in browser
305
+
constmemoryLock=require('ipfs-repo/src/lock-memory') // Default in browser
306
306
```
307
307
308
-
#### `lock.open (dir, callback)`
308
+
You can also provide your own custom Lock. It must be an object with the following interface:
309
309
310
-
Sets the lock if one does not already exist.
310
+
#### `lock.lock (dir, callback)`
311
+
312
+
Sets the lock if one does not already exist. If a lock already exists, `callback` should be called with an error.
311
313
312
314
`dir` is a string to the directory the lock should be created at. The repo typically creates the lock at its root.
0 commit comments