dagmodifier: Don't lose pin if old and new key happen to be equal
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Tommi Virtanen committed
Jun 8, 2015 at 21:43 UTC
b24de97b04cf33fc3908fe0de025b108e195f8e2
1 file changed
+3
-2
unixfs/mod/dagmodifier.go
+3
-2
@@ -209,9 +209,10 @@ func (dm *DagModifier) Sync() error {
209
dm.curNode = nd
210
}
211
212
- // Finalize correct pinning, and flush pinner
213
- dm.mp.PinWithMode(thisk, pin.Recursive)
212
+ // Finalize correct pinning, and flush pinner.
213
+ // Be careful about the order, as curk might equal thisk.
214
dm.mp.RemovePinWithMode(curk, pin.Recursive)
215
+ dm.mp.PinWithMode(thisk, pin.Recursive)
216
err = dm.mp.Flush()
217
if err != nil {
218
return err