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
+33-2Lines changed: 33 additions & 2 deletions
Display the source diff
Display the rich diff
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, defaults to `"fs"`in Node.js, `"memory"` in the browser): what type of lock to use. Lock has to be acquired when opening.
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.
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`.
@@ -284,7 +284,7 @@ Sets the API address.
284
284
285
285
### `repo.stat ([options], callback)`
286
286
287
-
Gets the repo status.
287
+
Gets the repo status.
288
288
289
289
`options` is an object which might contain the key `human`, which is a boolean indicating whether or not the `repoSize` should be displayed in MiB or not.
290
290
@@ -296,6 +296,37 @@ Gets the repo status.
296
296
-`version`
297
297
-`storageMax`
298
298
299
+
### Lock
300
+
301
+
IPFS Repo comes with two built in locks: memory and fs. These can be imported via the following:
302
+
303
+
```js
304
+
constfsLock=require('ipfs-repo/lock') // Default in Node.js
305
+
constmemLock=require('ipfs-repo/lock-memory') // Default in browser
306
+
```
307
+
308
+
#### `lock.open (dir, callback)`
309
+
310
+
Sets the lock if one does not already exist.
311
+
312
+
`dir` is a string to the directory the lock should be created at. The repo typically creates the lock at its root.
313
+
314
+
`callback` is a function with the signature `function (err, closer)`, where `closer` has a `close` method for removing the lock.
315
+
316
+
##### `closer.close (callback)`
317
+
318
+
Closes the lock created by `lock.open`
319
+
320
+
`callback` is a function with the signature `function (err)`. If no error was returned, the lock was successfully removed.
321
+
322
+
#### `lock.locked (dir, callback)`
323
+
324
+
Checks the existence of the lock.
325
+
326
+
`dir` is a string to the directory to check for the lock. The repo typically checks for the lock at its root.
327
+
328
+
`callback` is a function with the signature `function (err, boolean)`, where `boolean` indicates the existence of the lock.
329
+
299
330
## Notes
300
331
301
332
-[Explanation of how repo is structured](https://github.com/ipfs/js-ipfs-repo/pull/111#issuecomment-279948247)
0 commit comments