Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f20b727

Browse files
committedJan 5, 2016
take a pin lock while performing ipfs files operations
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent 1c1f9c6 commit f20b727

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎core/commands/files/files.go

+24
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ var FilesStatCmd = &cmds.Command{
5959
return
6060
}
6161

62+
// take the lock and defer the unlock
63+
defer node.Blockstore.PinLock()()
64+
6265
path, err := checkPath(req.Arguments()[0])
6366
if err != nil {
6467
res.SetError(err, cmds.ErrNormal)
@@ -138,6 +141,9 @@ var FilesCpCmd = &cmds.Command{
138141
return
139142
}
140143

144+
// take the lock and defer the unlock
145+
defer node.Blockstore.PinLock()()
146+
141147
src, err := checkPath(req.Arguments()[0])
142148
if err != nil {
143149
res.SetError(err, cmds.ErrNormal)
@@ -233,6 +239,9 @@ Examples:
233239
return
234240
}
235241

242+
// take the lock and defer the unlock
243+
defer nd.Blockstore.PinLock()()
244+
236245
fsn, err := mfs.Lookup(nd.FilesRoot, path)
237246
if err != nil {
238247
res.SetError(err, cmds.ErrNormal)
@@ -323,6 +332,9 @@ Examples:
323332
return
324333
}
325334

335+
// take the lock and defer the unlock
336+
defer n.Blockstore.PinLock()()
337+
326338
path, err := checkPath(req.Arguments()[0])
327339
if err != nil {
328340
res.SetError(err, cmds.ErrNormal)
@@ -409,6 +421,9 @@ Example:
409421
return
410422
}
411423

424+
// take the lock and defer the unlock
425+
defer n.Blockstore.PinLock()()
426+
412427
src, err := checkPath(req.Arguments()[0])
413428
if err != nil {
414429
res.SetError(err, cmds.ErrNormal)
@@ -484,6 +499,9 @@ Warning:
484499
return
485500
}
486501

502+
// take the lock and defer the unlock
503+
defer nd.Blockstore.PinLock()()
504+
487505
offset, _, err := req.Option("offset").Int()
488506
if err != nil {
489507
res.SetError(err, cmds.ErrNormal)
@@ -579,6 +597,9 @@ Examples:
579597
return
580598
}
581599

600+
// take the lock and defer the unlock
601+
defer n.Blockstore.PinLock()()
602+
582603
dashp, _, _ := req.Option("parents").Bool()
583604
dirtomake, err := checkPath(req.Arguments()[0])
584605
if err != nil {
@@ -628,6 +649,9 @@ remove files or directories
628649
return
629650
}
630651

652+
// take the lock and defer the unlock
653+
defer nd.Blockstore.PinLock()()
654+
631655
path, err := checkPath(req.Arguments()[0])
632656
if err != nil {
633657
res.SetError(err, cmds.ErrNormal)

0 commit comments

Comments
 (0)
Please sign in to comment.