From 87359fc898d9068d5ee60e15c31060094f13f6c7 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 21 Aug 2019 09:36:51 -0700 Subject: [PATCH] make delete idempotent fixes https://github.com/ipfs/go-datastore/issues/104 --- datastore.go | 10 ---------- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/datastore.go b/datastore.go index 1b2df12..6f8a610 100644 --- a/datastore.go +++ b/datastore.go @@ -99,16 +99,6 @@ func (d *accessor) GetSize(key ds.Key) (size int, err error) { } func (a *accessor) Delete(key ds.Key) (err error) { - // leveldb Delete will not return an error if the key doesn't - // exist (see https://github.com/syndtr/goleveldb/issues/109), - // so check that the key exists first and if not return an - // error - exists, err := a.ldb.Has(key.Bytes(), nil) - if !exists { - return ds.ErrNotFound - } else if err != nil { - return err - } return a.ldb.Delete(key.Bytes(), nil) } diff --git a/go.mod b/go.mod index d26e1c1..121eea7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ipfs/go-ds-leveldb require ( - github.com/ipfs/go-datastore v0.0.3 + github.com/ipfs/go-datastore v0.1.0 github.com/syndtr/goleveldb v1.0.0 ) diff --git a/go.sum b/go.sum index d6ecf9b..12cceb1 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ipfs/go-datastore v0.0.3 h1:/eP3nMDmLzMJNoWSSYvEkmMTTrm9FFCN+JraP9NdlwU= -github.com/ipfs/go-datastore v0.0.3/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= +github.com/ipfs/go-datastore v0.1.0 h1:TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI= +github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8 h1:bspPhN+oKYFk5fcGNuQzp6IGzYQSenLEgH3s6jkXrWw= github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY=