Skip to content

Commit 71e458c

Browse files
authored
Merge pull request #30 from ipfs/fix/idempotent-delete
make delete idempotent
2 parents 47a9627 + 87359fc commit 71e458c

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

datastore.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ func (d *accessor) GetSize(key ds.Key) (size int, err error) {
9999
}
100100

101101
func (a *accessor) Delete(key ds.Key) (err error) {
102-
// leveldb Delete will not return an error if the key doesn't
103-
// exist (see https://github.com/syndtr/goleveldb/issues/109),
104-
// so check that the key exists first and if not return an
105-
// error
106-
exists, err := a.ldb.Has(key.Bytes(), nil)
107-
if !exists {
108-
return ds.ErrNotFound
109-
} else if err != nil {
110-
return err
111-
}
112102
return a.ldb.Delete(key.Bytes(), nil)
113103
}
114104

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ipfs/go-ds-leveldb
22

33
require (
4-
github.com/ipfs/go-datastore v0.0.3
4+
github.com/ipfs/go-datastore v0.1.0
55
github.com/syndtr/goleveldb v1.0.0
66
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
1010
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1111
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
1212
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
13-
github.com/ipfs/go-datastore v0.0.3 h1:/eP3nMDmLzMJNoWSSYvEkmMTTrm9FFCN+JraP9NdlwU=
14-
github.com/ipfs/go-datastore v0.0.3/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
13+
github.com/ipfs/go-datastore v0.1.0 h1:TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI=
14+
github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
1515
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
1616
github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5fcGNuQzp6IGzYQSenLEgH3s6jkXrWw=
1717
github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY=

0 commit comments

Comments
 (0)