goleveldb
goleveldb copied to clipboard
OpenFile() with &Opts{ReadOnly: true} returns leveldb/storage: storage is read-only
Hi,
This is an excerpt of my wrapper function:
func NewGoLevelDBWithOpts(name string, dir string, o *opt.Options) (*GoLevelDB, error) {
dbPath := filepath.Join(dir, name+".db")
db, err := leveldb.OpenFile(dbPath, o)
if err != nil {
return nil, err
}
database := &GoLevelDB{
db: db,
}
return database, nil
}
When I pass &Opts{ReadOnly: true}
to the function, it returns nil, error
. The error in particular complains about the storage being read-only, which is incidentally what I asked for by setting ReadOnly
to true.
Thanks for considering.
@syndtr it'd be nice if you could have a look
How is this PR going? Is there ETA that goleveldb owner will merge it? Thanks!
What PR?
I've had make changes on f908035 but have yet to have time to verify whether that fixed the issue or investigate whether they're other bug that cause thus. @alessio let me know whether f908035 fix this or not? Thanks!
yes I mean this commit https://github.com/syndtr/goleveldb/commit/f9080354173f192dfc8821931eacf9cfd6819253
No, f908035 doesn't fix this
@syndtr if ReadOnly
is true and the path of db is empty ( or no CURRENT
and MANIFEST
), the fileStorage
still tries to create a MANIFEST
by calling Create
and causes the issue.
I've commit a pr (https://github.com/syndtr/goleveldb/pull/250) to fix this but I think the implement is kind of twisted.