Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-leveldb
Commits
fa5ecb98
Commit
fa5ecb98
authored
Jun 11, 2016
by
Jakub Sztandera
Committed by
GitHub
Jun 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from ipfs-filestore/leveldb-fix
Fix bug in LevelDB datastore's Delete() method.
parents
ecbf097e
d518920f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
datastore.go
datastore.go
+9
-3
No files found.
datastore.go
View file @
fa5ecb98
...
@@ -58,11 +58,17 @@ func (d *datastore) Has(key ds.Key) (exists bool, err error) {
...
@@ -58,11 +58,17 @@ func (d *datastore) Has(key ds.Key) (exists bool, err error) {
}
}
func
(
d
*
datastore
)
Delete
(
key
ds
.
Key
)
(
err
error
)
{
func
(
d
*
datastore
)
Delete
(
key
ds
.
Key
)
(
err
error
)
{
err
=
d
.
DB
.
Delete
(
key
.
Bytes
(),
nil
)
// leveldb Delete will not return an error if the key doesn't
if
err
==
leveldb
.
ErrNotFound
{
// exist (see https://github.com/syndtr/goleveldb/issues/109),
// so check that the key exists first and if not return an
// error
exists
,
err
:=
d
.
DB
.
Has
(
key
.
Bytes
(),
nil
)
if
!
exists
{
return
ds
.
ErrNotFound
return
ds
.
ErrNotFound
}
else
if
err
!=
nil
{
return
err
}
}
return
err
return
d
.
DB
.
Delete
(
key
.
Bytes
(),
nil
)
}
}
func
(
d
*
datastore
)
Query
(
q
dsq
.
Query
)
(
dsq
.
Results
,
error
)
{
func
(
d
*
datastore
)
Query
(
q
dsq
.
Query
)
(
dsq
.
Results
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment