Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open/read does not fail on invalid file #18

Closed
dsoprea opened this issue May 1, 2019 · 3 comments
Closed

Open/read does not fail on invalid file #18

dsoprea opened this issue May 1, 2019 · 3 comments

Comments

@dsoprea
Copy link

dsoprea commented May 1, 2019

Recently I realized I was opening the wrong database and it took me an hour to figure it out because (*DB).FileSize() was returning non-zero and (*DB).Count() was returning zero, and there were no errors reported by (*DB).Open(). We have no standard way to figure out if the DB is invalid?

As a bonus, doing this will also change the target file even if it wasn't a correct/working database file to begin with.

@akrylysov
Copy link
Owner

Interesting, pogreb checks the file header when it opens the database file (https://github.com/akrylysov/pogreb/blob/master/db.go#L193), but it does it only for the index. I'll add an additional check, thanks for the report!

@dsoprea
Copy link
Author

dsoprea commented May 2, 2019

Your project had yet to be exposed to the right class of moron, and I'm here to help.

@akrylysov
Copy link
Owner

The issue was fixed in 3108cc9, thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants