Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Delay clearing db.path until just before db.close returns. #550

Merged
merged 1 commit into from
Apr 7, 2016

Conversation

ChrisHines
Copy link
Contributor

The Windows version of funlock needs the db.path to delete the
corresponding .lock file.

Fix for #549.

// defer clearing the path because funlock may need it.
defer func() {
db.path = ""
}()
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this down to just before the return nil at the end of the function? I'd rather not have a defer if it's not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it OK to leave the field populated if one of the error return paths is taken? What invariant is implied by setting db.path = ""?

Copy link
Member

Choose a reason for hiding this comment

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

There's not an explicit guarantee about path when an error occurs. Honestly, I wish I hadn't reset the path at all on Close() but that's behavior now. I'm OK with changing the behavior on error to not clear the path.

The Windows version of funlock needs the db.path to delete the
corresponding .lock file.
@ChrisHines
Copy link
Contributor Author

@benbjohnson PR updated, PTAL.

@ChrisHines ChrisHines changed the title Defer clearing db.path until db.close returns. Delay clearing db.path until just before db.close returns. Apr 7, 2016
@benbjohnson benbjohnson merged commit 144418e into boltdb:master Apr 7, 2016
@benbjohnson
Copy link
Member

Thanks @ChrisHines! 👍

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

Successfully merging this pull request may close these issues.

2 participants