Skip to content

Commit

Permalink
Merge pull request #3222 from ipfs/kevina/add-no-pin-lock
Browse files Browse the repository at this point in the history
Adder: Don't hold the PinLock when not pinning.
  • Loading branch information
whyrusleeping committed Sep 14, 2016
2 parents 98fdffa + 7bf30c3 commit 73cd8b3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,13 @@ func (adder *Adder) addNode(node *dag.Node, path string) error {

// Add the given file while respecting the adder.
func (adder *Adder) AddFile(file files.File) error {
adder.unlocker = adder.blockstore.PinLock()
if adder.Pin {
adder.unlocker = adder.blockstore.PinLock()
}
defer func() {
adder.unlocker.Unlock()
if adder.unlocker != nil {
adder.unlocker.Unlock()
}
}()

return adder.addFile(file)
Expand Down Expand Up @@ -432,7 +436,7 @@ func (adder *Adder) addDir(dir files.File) error {
}

func (adder *Adder) maybePauseForGC() error {
if adder.blockstore.GCRequested() {
if adder.unlocker != nil && adder.blockstore.GCRequested() {
err := adder.PinRoot()
if err != nil {
return err
Expand Down

0 comments on commit 73cd8b3

Please sign in to comment.