fix delete logic
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Jan 24, 2017 at 15:46 UTC
36feaa4b109ced7ce62ba1de8645e3f5a08a674b
1 file changed
+12
-7
filestore/filestore.go
+12
-7
@@ -89,16 +89,21 @@ func (f *Filestore) DeleteBlock(c *cid.Cid) error {
89
return err1
90
}
91
92
- if err2 := f.fm.DeleteBlock(c); err2 != nil {
93
- // if we successfully removed something from the blockstore, but the
94
- // filestore didnt have it, return success
95
- if err1 == nil && err2 != blockstore.ErrNotFound {
96
- return nil
92
+ err2 := f.fm.DeleteBlock(c)
93
+ // if we successfully removed something from the blockstore, but the
94
+ // filestore didnt have it, return success
95
+
96
+ switch err2 {
97
+ case nil:
98
+ return nil
99
+ case blockstore.ErrNotFound:
100
+ if err1 == blockstore.ErrNotFound {
101
+ return blockstore.ErrNotFound
102
}
103
+ return nil
104
+ default:
105
return err2
106
}
100
-
101
- return nil
107
}
108
109
func (f *Filestore) Get(c *cid.Cid) (blocks.Block, error) {