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

Remove per-operation Open()/Close() calls to BoltDB #316

Merged
merged 1 commit into from
Aug 3, 2015

Conversation

js-ojus
Copy link

@js-ojus js-ojus commented Aug 1, 2015

  • Context now maintains a DB handle that is kept alive

@@ -410,6 +410,8 @@ func (cmd *indexCmd) Run(args []string) {
byId := *cmd.byId
byMatches := *cmd.matches
sources, context, path := preprocessArgsByToggle(args, byMatches || byId)
context.OpenDB()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to handle at least OpenDB() errors, please set it to

exitWithError(context.OpenDB())

@odeke-em
Copy link
Owner

odeke-em commented Aug 2, 2015

I've added a few comments.
Also please do this for indexCmd

--git a/cmd/drive/main.go b/cmd/drive/main.go
index b417f20..f43d837 100644
--- a/cmd/drive/main.go
+++ b/cmd/drive/main.go
@@ -411,6 +411,9 @@ func (cmd *indexCmd) Run(args []string) {
    byMatches := *cmd.matches
    sources, context, path := preprocessArgsByToggle(args, byMatches || byId)

+   exitWithError(context.OpenDB())
+   defer context.CloseDB()
+
    options := &drive.Options{
        Sources:           sources,
        Hidden:            *cmd.hidden,

@js-ojus
Copy link
Author

js-ojus commented Aug 3, 2015

I have made the suggested changes @odeke-em! Please take a look at it again.

}

func (c *Context) CloseDB() error {
return c.DB.Close()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if c.DB == nil {
    return errors.New("nil dereference of db")
}
return c.DB.Close()

@odeke-em
Copy link
Owner

odeke-em commented Aug 3, 2015

Thanks @js-ojus, just one more and then we are good to go.

@odeke-em
Copy link
Owner

odeke-em commented Aug 3, 2015

Once that is in, please help me squash the commits into one and then I'll merge it in.
Thank you again.

* `Context` now maintains a DB handle that is kept alive
@js-ojus
Copy link
Author

js-ojus commented Aug 3, 2015

Hello @odeke-em! I have squashed the commits into a single one, which is now reflected in the pull request.

@odeke-em
Copy link
Owner

odeke-em commented Aug 3, 2015

LGTM! Thank you very much for diagnosing, and working on this.

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

Successfully merging this pull request may close these issues.

2 participants