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

omit slash from created dskeys #41

Merged
merged 1 commit into from
Jun 28, 2016
Merged

omit slash from created dskeys #41

merged 1 commit into from
Jun 28, 2016

Conversation

whyrusleeping
Copy link
Member

re: @kevina's comments after my last PR

@@ -56,7 +56,7 @@ func New(path string, prefixLen int, sync bool) (*Datastore, error) {
var padding = strings.Repeat("_", maxPrefixLen)

func (fs *Datastore) encode(key datastore.Key) (dir, file string) {
prefix := (key.String() + padding)[:fs.prefixLen]
prefix := (key.String() + padding)[1:fs.prefixLen]
dir = path.Join(fs.path, prefix)
file = path.Join(dir, key.String()+extension)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be:

noslash := key.String()[1:]
prefix := (noslash + padding)[:fs.prefixLen]
dir = path.Join(fs.path, prefix)
file = path.Join(dir, noslash+extension)

as go slices are [start:stop] not [start:len].

@kevina
Copy link
Contributor

kevina commented Jun 28, 2016

LGTM.

@whyrusleeping whyrusleeping merged commit 4d340af into master Jun 28, 2016
@whyrusleeping whyrusleeping deleted the fix/omit-slash branch June 28, 2016 21:29
@Kubuxu
Copy link
Member

Kubuxu commented Jun 28, 2016

LGTM.

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.

3 participants